Skip to content

Commit

Permalink
git-am: use printf instead of echo on user-supplied strings
Browse files Browse the repository at this point in the history
Under some implementations of echo (such as that provided by
dash), backslash escapes are recognized without any other
options. This means that echo-ing user-supplied strings may
cause any backslash sequences in them to be converted. Using
printf resolves the ambiguity.

This bug can be seen when using git-am to apply a patch
whose subject contains the character sequence "\n"; the
characters are converted to a literal newline. Noticed by
Szekeres Istvan.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 26, 2007
1 parent c1bab28 commit 4b7cc26
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ do
ADD_SIGNOFF=
fi
{
echo "$SUBJECT"
printf '%s\n' "$SUBJECT"
if test -s "$dotest/msg-clean"
then
echo
Expand Down Expand Up @@ -394,7 +394,7 @@ do
fi

echo
echo "Applying '$SUBJECT'"
printf 'Applying %s\n' "$SUBJECT"
echo

case "$resolved" in
Expand Down

0 comments on commit 4b7cc26

Please sign in to comment.