git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Gernhardt <benji@silverinsanity.com>
To: Git List <git@vger.kernel.org>
Cc: Shawn O Pearce <spearce@spearce.org>
Subject: [PATCH] Avoid using non-portable `echo -n` in tests.
Date: Fri, 31 Oct 2008 01:09:13 -0400	[thread overview]
Message-ID: <1225429753-70109-1-git-send-email-benji@silverinsanity.com> (raw)
In-Reply-To: <8A4A84EC-51F7-4038-957C-CCA5C00E5977@silverinsanity.com>

Not all /bin/sh have a builtin echo that recognizes -n.  Using printf
is far more portable.

Discovered on OS X 10.5.5 in t4030-diff-textconv.sh and changed in all
the test scripts.

Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
---
 t/t2005-checkout-index-symlinks.sh |    2 +-
 t/t2102-update-index-symlinks.sh   |    4 ++--
 t/t4030-diff-textconv.sh           |    2 +-
 t/t6025-merge-symlinks.sh          |    4 ++--
 t/t9400-git-cvsserver-server.sh    |    2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/t/t2005-checkout-index-symlinks.sh b/t/t2005-checkout-index-symlinks.sh
index ed12c4d..9fa5610 100755
--- a/t/t2005-checkout-index-symlinks.sh
+++ b/t/t2005-checkout-index-symlinks.sh
@@ -13,7 +13,7 @@ file if core.symlinks is false.'
 test_expect_success \
 'preparation' '
 git config core.symlinks false &&
-l=$(echo -n file | git hash-object -t blob -w --stdin) &&
+l=$(printf file | git hash-object -t blob -w --stdin) &&
 echo "120000 $l	symlink" | git update-index --index-info'
 
 test_expect_success \
diff --git a/t/t2102-update-index-symlinks.sh b/t/t2102-update-index-symlinks.sh
index f195aef..1ed44ee 100755
--- a/t/t2102-update-index-symlinks.sh
+++ b/t/t2102-update-index-symlinks.sh
@@ -13,12 +13,12 @@ even if a plain file is in the working tree if core.symlinks is false.'
 test_expect_success \
 'preparation' '
 git config core.symlinks false &&
-l=$(echo -n file | git hash-object -t blob -w --stdin) &&
+l=$(printf file | git hash-object -t blob -w --stdin) &&
 echo "120000 $l	symlink" | git update-index --index-info'
 
 test_expect_success \
 'modify the symbolic link' '
-echo -n new-file > symlink &&
+printf new-file > symlink &&
 git update-index symlink'
 
 test_expect_success \
diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh
index 3945731..a235955 100755
--- a/t/t4030-diff-textconv.sh
+++ b/t/t4030-diff-textconv.sh
@@ -105,7 +105,7 @@ index ad8b3d2..67be421
 EOF
 # make a symlink the hard way that works on symlink-challenged file systems
 test_expect_success 'textconv does not act on symlinks' '
-	echo -n frotz > file &&
+	printf frotz > file &&
 	git add file &&
 	git ls-files -s | sed -e s/100644/120000/ |
 		git update-index --index-info &&
diff --git a/t/t6025-merge-symlinks.sh b/t/t6025-merge-symlinks.sh
index 53892a5..433c4de 100755
--- a/t/t6025-merge-symlinks.sh
+++ b/t/t6025-merge-symlinks.sh
@@ -18,11 +18,11 @@ git add file &&
 git commit -m initial &&
 git branch b-symlink &&
 git branch b-file &&
-l=$(echo -n file | git hash-object -t blob -w --stdin) &&
+l=$(printf file | git hash-object -t blob -w --stdin) &&
 echo "120000 $l	symlink" | git update-index --index-info &&
 git commit -m master &&
 git checkout b-symlink &&
-l=$(echo -n file-different | git hash-object -t blob -w --stdin) &&
+l=$(printf file-different | git hash-object -t blob -w --stdin) &&
 echo "120000 $l	symlink" | git update-index --index-info &&
 git commit -m b-symlink &&
 git checkout b-file &&
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index c1850d2..f6a2dbd 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -424,7 +424,7 @@ cd "$WORKDIR"
 test_expect_success 'cvs update (-p)' '
     touch really-empty &&
     echo Line 1 > no-lf &&
-    echo -n Line 2 >> no-lf &&
+    printf Line 2 >> no-lf &&
     git add really-empty no-lf &&
     git commit -q -m "Update -p test" &&
     git push gitcvs.git >/dev/null &&
-- 
1.6.0.3.757.g1e5a4

  reply	other threads:[~2008-10-31  5:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-30 22:12 [PATCH] t4030: Don't use echo -n Brian Gernhardt
2008-10-30 23:52 ` Ian Hilt
2008-10-31  5:02   ` Brian Gernhardt
2008-10-31  5:09     ` Brian Gernhardt [this message]
2008-10-31  8:15       ` [PATCH] Avoid using non-portable `echo -n` in tests Junio C Hamano
2008-10-31 15:38         ` Brian Gernhardt
2008-10-31  8:20       ` Junio C Hamano
2008-10-31  9:36         ` [PATCH] Avoid using non-portable `echo-n` " Steve Folly
2008-10-31 14:32       ` [PATCH] Avoid using non-portable `echo -n` " Shawn O. Pearce
2008-10-31 18:24       ` Jeff King
2008-10-31 18:36         ` Pierre Habouzit
2008-10-31 18:39           ` Jeff King
2008-10-31 19:35             ` Francis Galiegue
2008-10-31 22:53               ` Johannes Schindelin
2008-11-03 16:30         ` Mike Ralphson
  -- strict thread matches above, loose matches on Subject: below --
2008-10-31 19:50 Francis Galiegue
2008-10-31 20:10 ` Junio C Hamano
2008-10-31 20:11 ` Ian Hilt
2008-10-31 20:30   ` Francis Galiegue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1225429753-70109-1-git-send-email-benji@silverinsanity.com \
    --to=benji@silverinsanity.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).