From: Jonathan Nieder Date: Sat, 08 Jan 2011 18:22:01 GMT Subject: Re: [PATCH] Avoid unportable nested double- and backquotes in shell scripts. Message-ID: <20110108182201.GB29788@burratino> In-Reply-To: <20110108164825.GC28898@burratino> Jonathan Nieder wrote: > 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 1 sum 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 3133 So 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 }