Re: [PATCH] pull: replace unnecessary sed invocation
- From
- Brandon Casey <brandon.casey.ctr@nrlssc.navy.mil>
- Date
- Mar 18, 2010, 14:46 UTC
- Message-ID
- <5rEymC6ZWmCbugaX54NzNsnDmRUKU5-au3DQ0l_p5YIjUz7xRlUzXA@cipher.nrlssc.navy.mil>
- In-Reply-To
- <4BA22AEE.8000606@gmail.com>
On 03/18/2010 08:30 AM, Gabriel Filion wrote:
Show 10 quoted lines
> On 2010-03-18 01:10, Stephen Boyd wrote:
>> Getting the shortened branch name is as easy as using the shell's
>> parameter expansion.
>>
>> curr_branch=$(git symbolic-ref -q HEAD)
>> -curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
>> +curr_branch_short="${curr_branch#refs/heads/}"
>
> This modification is a bashism. This syntax is not compatible with other
> shells.But, there is already precedence for using syntax in scripts, so it is probably ok.
$ egrep -- '\$\{[^}]+#[^}]+\}' *.sh git-bisect.sh: start_head="${head#refs/heads/}" git-filter-branch.sh: ref="${ref#refs/tags/}" git-parse-remote.sh: heads/*) remote=${remote#heads/} ;; git-parse-remote.sh: refs/heads/*) remote=${remote#refs/heads/} ;; git-pull.sh: curr_branch=${curr_branch#refs/heads/} git-pull.sh: echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'" git-rebase--interactive.sh: pend="${pend# $p}" git-rebase--interactive.sh: new_parents=${new_parents# $first_parent} git-rebase--interactive.sh: if left=${1%...*} right=${1#*...} && git-rebase.sh: eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"' git-rebase.sh: if left=${onto_name%...*} right=${onto_name#*...} && git-stash.sh: branch=${branch#refs/heads/} git-submodule.sh: url="${url#../}" git-submodule.sh: url="${url#./}"