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 <peff@peff.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jeff King committed
May 25, 2007 at 23:42 UTC
4b7cc26a74b01ceab14a32ef66704557b26d5622
1 file changed
+2
-2
git-am.sh
+2
-2
@@ -331,7 +331,7 @@ do
331
ADD_SIGNOFF=
332
fi
333
{
334
- echo "$SUBJECT"
334
+ printf '%s\n' "$SUBJECT"
335
if test -s "$dotest/msg-clean"
336
then
337
echo
@@ -394,7 +394,7 @@ do
394
fi
395
396
echo
397
- echo "Applying '$SUBJECT'"
397
+ printf 'Applying %s\n' "$SUBJECT"
398
echo
399
400
case "$resolved" in