git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use printf rather than echo -n.
@ 2005-12-06 22:21 Jason Riedy
  2005-12-07  2:04 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Riedy @ 2005-12-06 22:21 UTC (permalink / raw)
  To: git


On AIX, there is no -n option to the system's echo.  Instead,
it needs the '\c' control character.  We could replace
  echo -n "foo"
with
  echo -e "foo\c"
but printf is recommended by most man pages.  Tested on AIX
5.3, Solaris 8, and Debian.

Signed-off-by: E. Jason Riedy <ejr@cs.berkeley.edu>

---

 git-am.sh         |    2 +-
 git-applypatch.sh |    2 +-
 git-bisect.sh     |    2 +-
 git-status.sh     |    4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

58ad3dda17daa0577fda5204f75bbc846cf7d7ea
diff --git a/git-am.sh b/git-am.sh
index 660b3a4..6ed527c 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -312,7 +312,7 @@ do
 		echo "--------------------------"
 		cat "$dotest/final-commit"
 		echo "--------------------------"
-		echo -n "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all "
+		printf "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all "
 		read reply
 		case "$reply" in
 		[yY]*) action=yes ;;
diff --git a/git-applypatch.sh b/git-applypatch.sh
index 4c577eb..a112e1a 100755
--- a/git-applypatch.sh
+++ b/git-applypatch.sh
@@ -83,7 +83,7 @@ while [ "$interactive" = yes ]; do
 	echo "--------------------------"
 	cat "$final"
 	echo "--------------------------"
-	echo -n "Apply? [y]es/[n]o/[e]dit/[a]ccept all "
+	printf "Apply? [y]es/[n]o/[e]dit/[a]ccept all "
 	read reply
 	case "$reply" in
 		y|Y) interactive=no;;
diff --git a/git-bisect.sh b/git-bisect.sh
index 68838f3..05dae8a 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -67,7 +67,7 @@ bisect_start() {
 	rm -rf "$GIT_DIR/refs/bisect/"
 	mkdir "$GIT_DIR/refs/bisect"
 	{
-	    echo -n "git-bisect start"
+	    printf "git-bisect start"
 	    sq "$@"
 	} >"$GIT_DIR/BISECT_LOG"
 	sq "$@" >"$GIT_DIR/BISECT_NAMES"
diff --git a/git-status.sh b/git-status.sh
index b90ffc1..bf0e66c 100755
--- a/git-status.sh
+++ b/git-status.sh
@@ -13,7 +13,7 @@ report () {
   trailer=""
   while read status name newname
   do
-    echo -n "$header"
+    printf "$header"
     header=""
     trailer="#
 "
@@ -27,7 +27,7 @@ report () {
     U ) echo "#	unmerged: $name";;
     esac
   done
-  echo -n "$trailer"
+  printf "$trailer"
   [ "$header" ]
 }
 
-- 
0.99.9.GIT

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use printf rather than echo -n.
  2005-12-06 22:21 [PATCH] Use printf rather than echo -n Jason Riedy
@ 2005-12-07  2:04 ` Junio C Hamano
  2005-12-07  3:31   ` Jason Riedy
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2005-12-07  2:04 UTC (permalink / raw)
  To: Jason Riedy; +Cc: git

Jason Riedy <ejr@EECS.Berkeley.EDU> writes:

> On AIX, there is no -n option to the system's echo.  Instead,
> it needs the '\c' control character.  We could replace
>   echo -n "foo"
> with
>   echo -e "foo\c"
> but printf is recommended by most man pages.  Tested on AIX
> 5.3, Solaris 8, and Debian.

Hmmmmmmmmmmmmmmmmmmmmmmmm.

Perhaps printf '%s' "$blah" to futureproof, instead of just
saying printf "$blah"?

<rant mode on>
While I do not have anything aginst system without "sane" echo,
I really do not like it.  Not your solution, but *having to do*
something like that.

metaconfig Configure does "echo $n frotz $c" with n=-n or c=\\c
set appropriately; autoconf does the same with $ac_n $ac_c.
IIRC, I think ancient autoconf did "echo | tr -d '\012'".  

These are far worse than a single printf, although they may be
more portable.

</rant mode off>

As a traditionalist, if I were doing it myself I would probably
pipe echo to tr, but I am lazy so I'd take your patch as is ;-).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use printf rather than echo -n.
  2005-12-07  2:04 ` Junio C Hamano
@ 2005-12-07  3:31   ` Jason Riedy
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Riedy @ 2005-12-07  3:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

And Junio C Hamano writes:
 - Perhaps printf '%s' "$blah" to futureproof, instead of just
 - saying printf "$blah"?

Definitely more likely to stay correct.  I'm just lazy.

 - <rant mode on>
 - While I do not have anything aginst system without "sane" echo,
 - I really do not like it.  Not your solution, but *having to do*
 - something like that.

Um, you think the wrong one is sane.  ;)  Why should echo 
in Bourne shell take C-shell arguments?  (I blame AT&T for
their crappy licensing.)

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use printf rather than echo -n.
@ 2005-12-08  8:02 linux
  0 siblings, 0 replies; 4+ messages in thread
From: linux @ 2005-12-08  8:02 UTC (permalink / raw)
  To: ejr, git

I know it's pointless, but continuing the rant...

> On AIX, there is no -n option to the system's echo.

What the F***?  "echo -n" was added in 7th edition:
http://minnie.tuhs.org/UnixTree/V7/usr/src/cmd/echo.c.html
(It's not in 6th edition:
http://minnie.tuhs.org/UnixTree/V6/usr/source/s1/echo.c.html)

Now, I realize that AIX is derived from UCLA Locus, which branched
off from the Bell Labs source before 7th ed., but you'd think in the
intervening twenty-seven years someone would have had slightly more brains
than a pithed frog and have thought to add the 7th edition features?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-12-08  8:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-06 22:21 [PATCH] Use printf rather than echo -n Jason Riedy
2005-12-07  2:04 ` Junio C Hamano
2005-12-07  3:31   ` Jason Riedy
  -- strict thread matches above, loose matches on Subject: below --
2005-12-08  8:02 linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).