Re: [PATCH] Avoid unportable nested double- and backquotes in shell scripts.
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Jan 8, 2011, 18:22 UTC
- Message-ID
- <20110108182201.GB29788@burratino>
- In-Reply-To
- <20110108164825.GC28898@burratino>
Jonathan Nieder wrote:
Show 10 quoted lines
> From a quick grep, it seems you are right:
>
> $ git grep -c -F -e '`' -- 't/*.sh' | cut -d: -f2 | sum
> 65126 1
> $ git grep -c -F -e '$(' -- 't/*.sh' | cut -d: -f2 | sum
> 64807 1
> $ git grep -c -F -e '`' -- '*.sh' | cut -d: -f2 | sum
> 13350 1
> $ git grep -c -F -e '$(' -- '*.sh' | cut -d: -f2 | sum
> 07810 1sum does something totally different than I expected. With [1] comes the more reasonable
$ git grep -c -F -e '`' -- 't/*.sh' | cut -d: -f2 | addup
485
$ git grep -c -F -e '$(' -- 't/*.sh' | cut -d: -f2 | addup
2620
$ git grep -c -F -e '`' -- '*.sh' | cut -d: -f2 | addup
594
$ git grep -c -F -e '$(' -- '*.sh' | cut -d: -f2 | addup
3133So the code bloat and use of backticks are less dire than I feared.
[1]
addup () {
sum=0
while read term
do
: $((sum = $sum + $term))
done
echo $sum
}