From 4b7cc26a74b01ceab14a32ef66704557b26d5622 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 25 May 2007 23:42:36 -0400 Subject: [PATCH] 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 --- git-am.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- 2.30.2