From: Jeff King Date: Sat, 26 May 2007 03:42:36 +0000 (-0400) Subject: git-am: use printf instead of echo on user-supplied strings X-Git-Tag: v1.5.2.1~4^2~10 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4b7cc26;p=git.git git-am: use printf instead of echo on user-supplied strings 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 Signed-off-by: Junio C Hamano --- diff --git a/git-am.sh b/git-am.sh index c9f66e278..543efd0ad 100755 --- a/git-am.sh +++ b/git-am.sh @@ -331,7 +331,7 @@ do ADD_SIGNOFF= fi { - echo "$SUBJECT" + printf '%s\n' "$SUBJECT" if test -s "$dotest/msg-clean" then echo @@ -394,7 +394,7 @@ do fi echo - echo "Applying '$SUBJECT'" + printf 'Applying %s\n' "$SUBJECT" echo case "$resolved" in