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

Re: Corner case bug caused by shell dependent behavior

From
Jeff King <peff@peff.net>
Date
Mar 14, 2014, 02:28 UTC
Message-ID
<20140314022845.GA19757@sigill.intra.peff.net>
In-Reply-To
<20140314000213.GA3739@ibr.ch>
On Fri, Mar 14, 2014 at 01:02:13AM +0100, Uwe Storbeck wrote:
Show 13 quoted lines
> When your system shell (/bin/sh) is a dash control sequences in
> strings get interpreted by the echo command. A commit message
> which ends with the string '\n' may result in a garbage line in
> the todo list of an interactive rebase which causes the rebase
> to fail.
> 
> To reproduce the behavior (with dash as /bin/sh):
> 
>   mkdir test && cd test && git init
>   echo 1 >foo && git add foo
>   git commit -m"this commit message ends with '\n'"
>   echo 2 >foo && git commit -a --fixup HEAD
>   git rebase -i --autosquash --root

Hmph. We ran into this before and fixed all of the sites (e.g., d1c3b10 and 938791c). This one appears to have been added a few months later (by 68d5d03).

> Maybe there are more places where it would be more robust to use
> printf instead of echo.

FWIW, I just looked through the other uses of "echo" in git-rebase*.sh, and I think this is the only problematic case.

> -			echo "$sha1 $action $prefix $rest"
> +			printf "%s %s %s %s\n" "$sha1" "$action" "$prefix" "$rest"

Looks obviously correct. The echo just below here does not need the same treatment, as "$rest" is the problematic bit ("$prefix" is always "fixup" or "squash").

-Peff
Previous: Uwe StorbeckNext: David Kastrup
Message 4 of 5 in “Corner case bug caused by shell dependent behavior”
  1. Uwe StorbeckMar 14, 2014
  2. Jonathan NiederMar 14, 2014
  3. Uwe StorbeckMar 14, 2014
  4. Jeff KingMar 14, 2014
  5. David KastrupMar 14, 2014

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.