# [PATCH 1/4] t3300-funny-names: shell portability fixes

4 messages from 2006-05-26 to 2006-05-29. Participants: Eric Wong, Junio C Hamano.
Thread: https://gitlist.dev/t/4296

## Eric Wong, 2006-05-26 02:06

Subject: [PATCH 0/4] fix tests so they run without needing bash
Message-ID: <1148609178788-git-send-email-normalperson@yhbt.net>
URL: https://gitlist.dev/e/1148609178788-git-send-email-normalperson%40yhbt.net

```
I've tested these patches with bash, pdksh, and dash.  dash seems
to be 7s faster than bash (28s vs 35s) when running `make test',
and just a hair faster than pdksh.

Herbert:
patches #2 and #4 are required for dash, but not for pdksh.
I'm not sure about #2, but I'm pretty certain the problem #4 works
around is a bug in dash.

[PATCH 1/4] t3300-funny-names: shell portability fixes
[PATCH 2/4] tests: Remove heredoc usage inside quotes
[PATCH 3/4] t5500-fetch-pack: remove local (bashism) usage.
[PATCH 4/4] t6000lib: workaround a possible dash bug

-- 
Eric Wong

```

## Eric Wong, 2006-05-26 02:06

Subject: [PATCH 1/4] t3300-funny-names: shell portability fixes
Message-ID: <11486091783542-git-send-email-normalperson@yhbt.net>
URL: https://gitlist.dev/e/11486091783542-git-send-email-normalperson%40yhbt.net
In-Reply-To: <1148609178788-git-send-email-normalperson@yhbt.net>

```
echo isn't remotely standardized for handling backslashes,
so cat + heredoc seems better

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 t/t3300-funny-names.sh |   51 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 33 insertions(+), 18 deletions(-)

6b5ef54aa860b557f88084c1d642a611f7abcf4d
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 72a93da..c12270e 100755
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
@@ -40,9 +40,11 @@ test_expect_success 'git-ls-files no-fun
 t0=`git-write-tree`
 echo "$t0" >t0
 
-echo 'just space
+cat > expected <<\EOF
+just space
 no-funny
-"tabs\t,\" (dq) and spaces"' >expected
+"tabs\t,\" (dq) and spaces"
+EOF
 test_expect_success 'git-ls-files with-funny' \
 	'git-update-index --add "$p1" &&
 	git-ls-files >current &&
@@ -58,14 +60,18 @@ test_expect_success 'git-ls-files -z wit
 t1=`git-write-tree`
 echo "$t1" >t1
 
-echo 'just space
+cat > expected <<\EOF
+just space
 no-funny
-"tabs\t,\" (dq) and spaces"' >expected
+"tabs\t,\" (dq) and spaces"
+EOF
 test_expect_success 'git-ls-tree with funny' \
 	'git-ls-tree -r $t1 | sed -e "s/^[^	]*	//" >current &&
 	 diff -u expected current'
 
-echo 'A	"tabs\t,\" (dq) and spaces"' >expected
+cat > expected <<\EOF
+A	"tabs\t,\" (dq) and spaces"
+EOF
 test_expect_success 'git-diff-index with-funny' \
 	'git-diff-index --name-status $t0 >current &&
 	diff -u expected current'
@@ -84,53 +90,62 @@ test_expect_success 'git-diff-tree -z wi
 	'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
 	diff -u expected current'
 
-echo 'CNUM	no-funny	"tabs\t,\" (dq) and spaces"' >expected
+cat > expected <<\EOF
+CNUM	no-funny	"tabs\t,\" (dq) and spaces"
+EOF
 test_expect_success 'git-diff-tree -C with-funny' \
 	'git-diff-tree -C --find-copies-harder --name-status \
 		$t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
 	diff -u expected current'
 
-echo 'RNUM	no-funny	"tabs\t,\" (dq) and spaces"' >expected
+cat > expected <<\EOF
+RNUM	no-funny	"tabs\t,\" (dq) and spaces"
+EOF
 test_expect_success 'git-diff-tree delete with-funny' \
 	'git-update-index --force-remove "$p0" &&
 	git-diff-index -M --name-status \
 		$t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
 	diff -u expected current'
 
-echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
+cat > expected <<\EOF
+diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
 similarity index NUM%
 rename from no-funny
-rename to "tabs\t,\" (dq) and spaces"' >expected
-
+rename to "tabs\t,\" (dq) and spaces"
+EOF
 test_expect_success 'git-diff-tree delete with-funny' \
 	'git-diff-index -M -p $t0 |
 	 sed -e "s/index [0-9]*%/index NUM%/" >current &&
 	 diff -u expected current'
 
 chmod +x "$p1"
-echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
+cat > expected <<\EOF
+diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
 old mode 100644
 new mode 100755
 similarity index NUM%
 rename from no-funny
-rename to "tabs\t,\" (dq) and spaces"' >expected
-
+rename to "tabs\t,\" (dq) and spaces"
+EOF
 test_expect_success 'git-diff-tree delete with-funny' \
 	'git-diff-index -M -p $t0 |
 	 sed -e "s/index [0-9]*%/index NUM%/" >current &&
 	 diff -u expected current'
 
-echo >expected ' "tabs\t,\" (dq) and spaces"
- 1 files changed, 0 insertions(+), 0 deletions(-)'
+cat >expected <<\EOF
+ "tabs\t,\" (dq) and spaces"
+ 1 files changed, 0 insertions(+), 0 deletions(-)
+EOF
 test_expect_success 'git-diff-tree rename with-funny applied' \
 	'git-diff-index -M -p $t0 |
 	 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
 	 diff -u expected current'
 
-echo >expected ' no-funny
+cat > expected <<\EOF
+ no-funny
  "tabs\t,\" (dq) and spaces"
- 2 files changed, 3 insertions(+), 3 deletions(-)'
-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+EOF
 test_expect_success 'git-diff-tree delete with-funny applied' \
 	'git-diff-index -p $t0 |
 	 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
-- 
1.3.2.g7d11

```

## Junio C Hamano, 2006-05-26 03:01

Subject: Re: [PATCH 0/4] fix tests so they run without needing bash
Message-ID: <7vu07dqyk8.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vu07dqyk8.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <1148609178788-git-send-email-normalperson@yhbt.net>

```
You are my hero.

I've really been wanting to get rid of bashism and trying to run
everything with dash was one of my goals.  Although recent trend
seems to indicate people are more interested in getting rid of
shell scripts altogether, it is nice to see somebody actually
cares.

```

## Eric Wong, 2006-05-29 05:39

Subject: Re: [PATCH 0/4] fix tests so they run without needing bash
Message-ID: <20060529053905.GD24077@localdomain>
URL: https://gitlist.dev/e/20060529053905.GD24077%40localdomain
In-Reply-To: <7vu07dqyk8.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano <junkio@cox.net> wrote:
> You are my hero.

:)

You and Linus have already been my heroes for a while.

I was very pleasantly surprised that all the git-*.sh files work fine
(for me, at least) and only the tests needed modification.

-- 
Eric Wong

```
