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

Re: POSIX woes in t7810.87: dash bash or bash dash?

From
Jeff King <peff@peff.net>
Date
Jun 20, 2011, 17:13 UTC
Message-ID
<20110620171307.GA5859@sigill.intra.peff.net>
In-Reply-To
<20110620110440.GA29270@elie>
On Mon, Jun 20, 2011 at 06:04:41AM -0500, Jonathan Nieder wrote:
Show 11 quoted lines
> Michael J Gruber wrote:
> 
> > echo "a\"b\n\"c"
> > a"b
> > "c
> >
> > t7810.87 breaks with dash because of this. Escaping the \n does not make
> > the test work with both either.
> 
> This seems to have slipped by because testing it requires USE_LIBPCRE
> to be set.  Thanks for catching it.

Yeah, I test with dash, too, and missed it because I hadn't enabled pcre.

Show 8 quoted lines
> > So I'd like to know which one's right
> > and (independently) how to make it work for both...
> 
> Both are right.  The simplest fix is to use printf, as in
> 
> 	printf "%s\n" "a\"b\n\"c"
> 
> See [1] and [2].
Yep. We've dealt with this before and used printf as the solution. E.g.:
  938791c (git-rebase--interactive.sh: use printf instead of echo to print commit message, 2010-07-22)
  4d2e283 (git-am: re-fix the diag message printing, 2009-01-18)
  a23bfae (More echo "$user_message" fixes., 2007-05-26)
  4b7cc26 (git-am: use printf instead of echo on user-supplied strings, 2007-05-25)
-Peff
Previous: Jonathan NiederNext: Junio C Hamano
Message 3 of 7 in “POSIX woes in t7810.87: dash bash or bash dash?”
  1. Michael J GruberJun 20, 2011
  2. Jonathan NiederJun 20, 2011
  3. Jeff KingJun 20, 2011
  4. Junio C HamanoJun 20, 2011
  5. Jeff KingJun 20, 2011
  6. Junio C HamanoJun 20, 2011
  7. Jeff KingJun 21, 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.