git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Avoid unportable nested double- and backquotes in shell scripts.

From
RWRalf Wildenhues <ralf.wildenhues@gmx.de>
Date
Jan 8, 2011, 16:23 UTC
Message-ID
<20110108162353.GB4786@gmx.de>
In-Reply-To
<20110108161441.GA28898@burratino>
* Jonathan Nieder wrote on Sat, Jan 08, 2011 at 05:14:41PM CET:
Show 8 quoted lines
> Ralf Wildenhues wrote:
> 
> > [Subject: Avoid unportable nested double- and backquotes in shell scripts]
> >
> > Some shells parse them wrongly, esp. pdksh.
> 
> How does it treat $( ) command substitutions?  (We use those more
> heavily and they are easier on the eyes anyway.)

Better (except for the usual problems when 'case ...)' comes into play). But git makes heavy use of "no quoting needed on RHS of assignment" anyway, so it seems like this would be a good move nonetheless. And the testsuite uses backticks a lot, it seems a move away from that should be done more uniformly?

Anyway, I'll be happy to respin in whatever form is acceptable.
Show 15 quoted lines
> > --- a/t/t9107-git-svn-migrate.sh
> > +++ b/t/t9107-git-svn-migrate.sh
> > @@ -94,7 +94,7 @@ test_expect_success 'migrate --minimize on old inited layout' '
> >  		echo "$svnrepo"$path > "$GIT_DIR"/svn/$ref/info/url ) || exit 1;
> >  	done &&
> >  	git svn migrate --minimize &&
> > -	test -z "`git config -l | grep "^svn-remote\.git-svn\."`" &&
> > +	! git config -l | grep "^svn-remote\.git-svn\." &&
> 
> I thought I remembered portability problems with the
> 
> 	! a | b
> 
> construct but it seems I am wrong; t7810-grep.sh uses that
> construct without trouble, at least.

Some non-Posix-conforming shells have problems with that too, e.g., Solaris /bin/sh, but I figured git wouldn't cater to them as I also saw other such uses in the tree.

Cheers, Ralf

Previous: Jonathan NiederNext: Jonathan Nieder
Message 3 of 6 in “Avoid unportable nested double- and backquotes in shell scripts.”
  1. Avoid unportable nested double- and backquotes in shell scripts.Ralf Wildenhues, Jan 8, 2011
  2. Jonathan NiederJan 8, 2011
  3. Ralf WildenhuesJan 8, 2011
  4. Jonathan NiederJan 8, 2011
  5. Jonathan NiederJan 8, 2011
  6. Junio C HamanoJan 10, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.