git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Avoid unportable nested double- and backquotes in shell scripts.
Date: Sat, 8 Jan 2011 12:22:01 -0600	[thread overview]
Message-ID: <20110108182201.GB29788@burratino> (raw)
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
	}

  reply	other threads:[~2011-01-08 18:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-08  9:01 [PATCH] Avoid unportable nested double- and backquotes in shell scripts Ralf Wildenhues
2011-01-08 16:14 ` Jonathan Nieder
2011-01-08 16:23   ` Ralf Wildenhues
2011-01-08 16:48     ` Jonathan Nieder
2011-01-08 18:22       ` Jonathan Nieder [this message]
2011-01-10 18:09 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110108182201.GB29788@burratino \
    --to=jrnieder@gmail.com \
    --cc=Ralf.Wildenhues@gmx.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).