{"thread":{"id":"2761","subject":"[PATCH] Use printf rather than echo -n.","startedAt":"2005-12-06T22:21:52Z","lastAt":"2005-12-07T03:31:43Z","messageCount":3,"participants":["Jason Riedy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"13289","messageId":"20512.1133907712@lotus.CS.Berkeley.EDU","threadId":"2761","inReplyTo":null,"subject":"[PATCH] Use printf rather than echo -n.","fromName":"Jason Riedy","fromEmail":"ejr@eecs.berkeley.edu","sentAt":"2005-12-06T22:21:52Z","receivedAt":"2005-12-06T22:21:52Z","isPatch":true,"sender":{"key":"ejr@eecs.berkeley.edu","avatar":"https://gravatar.com/avatar/547fa56f887cab01599edab4e9f813c949c1269e02714f20e0496c56185d9837?d=mp&s=160"},"body":"\nOn AIX, there is no -n option to the system's echo.  Instead,\nit needs the '\\c' control character.  We could replace\n  echo -n \"foo\"\nwith\n  echo -e \"foo\\c\"\nbut printf is recommended by most man pages.  Tested on AIX\n5.3, Solaris 8, and Debian.\n\nSigned-off-by: E. Jason Riedy <ejr@cs.berkeley.edu>\n\n---\n\n git-am.sh         |    2 +-\n git-applypatch.sh |    2 +-\n git-bisect.sh     |    2 +-\n git-status.sh     |    4 ++--\n 4 files changed, 5 insertions(+), 5 deletions(-)\n\n58ad3dda17daa0577fda5204f75bbc846cf7d7ea\ndiff --git a/git-am.sh b/git-am.sh\nindex 660b3a4..6ed527c 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -312,7 +312,7 @@ do\n \t\techo \"--------------------------\"\n \t\tcat \"$dotest/final-commit\"\n \t\techo \"--------------------------\"\n-\t\techo -n \"Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all \"\n+\t\tprintf \"Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all \"\n \t\tread reply\n \t\tcase \"$reply\" in\n \t\t[yY]*) action=yes ;;\ndiff --git a/git-applypatch.sh b/git-applypatch.sh\nindex 4c577eb..a112e1a 100755\n--- a/git-applypatch.sh\n+++ b/git-applypatch.sh\n@@ -83,7 +83,7 @@ while [ \"$interactive\" = yes ]; do\n \techo \"--------------------------\"\n \tcat \"$final\"\n \techo \"--------------------------\"\n-\techo -n \"Apply? [y]es/[n]o/[e]dit/[a]ccept all \"\n+\tprintf \"Apply? [y]es/[n]o/[e]dit/[a]ccept all \"\n \tread reply\n \tcase \"$reply\" in\n \t\ty|Y) interactive=no;;\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 68838f3..05dae8a 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -67,7 +67,7 @@ bisect_start() {\n \trm -rf \"$GIT_DIR/refs/bisect/\"\n \tmkdir \"$GIT_DIR/refs/bisect\"\n \t{\n-\t    echo -n \"git-bisect start\"\n+\t    printf \"git-bisect start\"\n \t    sq \"$@\"\n \t} >\"$GIT_DIR/BISECT_LOG\"\n \tsq \"$@\" >\"$GIT_DIR/BISECT_NAMES\"\ndiff --git a/git-status.sh b/git-status.sh\nindex b90ffc1..bf0e66c 100755\n--- a/git-status.sh\n+++ b/git-status.sh\n@@ -13,7 +13,7 @@ report () {\n   trailer=\"\"\n   while read status name newname\n   do\n-    echo -n \"$header\"\n+    printf \"$header\"\n     header=\"\"\n     trailer=\"#\n \"\n@@ -27,7 +27,7 @@ report () {\n     U ) echo \"#\tunmerged: $name\";;\n     esac\n   done\n-  echo -n \"$trailer\"\n+  printf \"$trailer\"\n   [ \"$header\" ]\n }\n \n-- \n0.99.9.GIT\n"},{"id":"13304","messageId":"7vfyp5zmqe.fsf@assigned-by-dhcp.cox.net","threadId":"2761","inReplyTo":"20512.1133907712@lotus.CS.Berkeley.EDU","subject":"Re: [PATCH] Use printf rather than echo -n.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-07T02:04:25Z","receivedAt":"2005-12-07T02:04:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jason Riedy <ejr@EECS.Berkeley.EDU> writes:\n\n> On AIX, there is no -n option to the system's echo.  Instead,\n> it needs the '\\c' control character.  We could replace\n>   echo -n \"foo\"\n> with\n>   echo -e \"foo\\c\"\n> but printf is recommended by most man pages.  Tested on AIX\n> 5.3, Solaris 8, and Debian.\n\nHmmmmmmmmmmmmmmmmmmmmmmmm.\n\nPerhaps printf '%s' \"$blah\" to futureproof, instead of just\nsaying printf \"$blah\"?\n\n<rant mode on>\nWhile I do not have anything aginst system without \"sane\" echo,\nI really do not like it.  Not your solution, but *having to do*\nsomething like that.\n\nmetaconfig Configure does \"echo $n frotz $c\" with n=-n or c=\\\\c\nset appropriately; autoconf does the same with $ac_n $ac_c.\nIIRC, I think ancient autoconf did \"echo | tr -d '\\012'\".  \n\nThese are far worse than a single printf, although they may be\nmore portable.\n\n</rant mode off>\n\nAs a traditionalist, if I were doing it myself I would probably\npipe echo to tr, but I am lazy so I'd take your patch as is ;-).\n"},{"id":"13307","messageId":"21616.1133926303@lotus.CS.Berkeley.EDU","threadId":"2761","inReplyTo":"7vfyp5zmqe.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Use printf rather than echo -n.","fromName":"Jason Riedy","fromEmail":"ejr@eecs.berkeley.edu","sentAt":"2005-12-07T03:31:43Z","receivedAt":"2005-12-07T03:31:43Z","isPatch":true,"sender":{"key":"ejr@eecs.berkeley.edu","avatar":"https://gravatar.com/avatar/547fa56f887cab01599edab4e9f813c949c1269e02714f20e0496c56185d9837?d=mp&s=160"},"body":"And Junio C Hamano writes:\n - Perhaps printf '%s' \"$blah\" to futureproof, instead of just\n - saying printf \"$blah\"?\n\nDefinitely more likely to stay correct.  I'm just lazy.\n\n - <rant mode on>\n - While I do not have anything aginst system without \"sane\" echo,\n - I really do not like it.  Not your solution, but *having to do*\n - something like that.\n\nUm, you think the wrong one is sane.  ;)  Why should echo \nin Bourne shell take C-shell arguments?  (I blame AT&T for\ntheir crappy licensing.)\n\nJason\n"}]}