# [PATCH] t6030: use $SHELL_PATH to invoke user's preferred shell instead of bare sh

4 messages from 2011-08-29 to 2011-08-30. Participants: Brandon Casey, Junio C Hamano.
Thread: https://gitlist.dev/t/28252

## Brandon Casey, 2011-08-29 20:09

Subject: [PATCH] t6030: use $SHELL_PATH to invoke user's preferred shell instead of bare sh
Message-ID: <Sn_8tnPB8FBe4C5QxoGkIRcdzJ2sLq_-h0oZ37fkrq42HJgWSlGgty_hMznS2ckiKKOg66yY7R2mRQqhJAzedr762dMKb_s6ELjELyGXyU-tkJzir-FnxhCkAIb3q1028d5FrBBy6EW3SXEPBMTYTw@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/Sn_8tnPB8FBe4C5QxoGkIRcdzJ2sLq_-h0oZ37fkrq42HJgWSlGgty_hMznS2ckiKKOg66yY7R2mRQqhJAzedr762dMKb_s6ELjELyGXyU-tkJzir-FnxhCkAIb3q1028d5FrBBy6EW3SXEPBMTYTw%40cipher.nrlssc.navy.mil

```
From: Brandon Casey <drafnel@gmail.com>

Some platforms (IRIX, Solaris) provide an ancient /bin/sh which chokes on
modern shell syntax like $().  SHELL_PATH is provided to allow the user to
specify a working sh, let's use it here.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t6030-bisect-porcelain.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 62125ec..c53af62 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -732,7 +732,7 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' "
 	git bisect reset &&
 	git checkout broken &&
 	git bisect start broken master --no-checkout &&
-	git bisect run sh -c '
+	git bisect run \"$SHELL_PATH\" -c '
 		GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) &&
 		git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ &&
 		git pack-objects --stdout >/dev/null < tmp.\$\$
-- 
1.7.6.1

```

## Junio C Hamano, 2011-08-30 20:15

Subject: Re: [PATCH] t6030: use $SHELL_PATH to invoke user's preferred shell instead of bare sh
Message-ID: <7vfwki1wqo.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vfwki1wqo.fsf%40alter.siamese.dyndns.org
In-Reply-To: <Sn_8tnPB8FBe4C5QxoGkIRcdzJ2sLq_-h0oZ37fkrq42HJgWSlGgty_hMznS2ckiKKOg66yY7R2mRQqhJAzedr762dMKb_s6ELjELyGXyU-tkJzir-FnxhCkAIb3q1028d5FrBBy6EW3SXEPBMTYTw@cipher.nrlssc.navy.mil>

```
Brandon Casey <casey@nrlssc.navy.mil> writes:

> From: Brandon Casey <drafnel@gmail.com>
>
> Some platforms (IRIX, Solaris) provide an ancient /bin/sh which chokes on
> modern shell syntax like $().  SHELL_PATH is provided to allow the user to
> specify a working sh, let's use it here.
>
> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
> ---
>  t/t6030-bisect-porcelain.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> index 62125ec..c53af62 100755
> --- a/t/t6030-bisect-porcelain.sh
> +++ b/t/t6030-bisect-porcelain.sh
> @@ -732,7 +732,7 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' "
>  	git bisect reset &&
>  	git checkout broken &&
>  	git bisect start broken master --no-checkout &&
> -	git bisect run sh -c '
> +	git bisect run \"$SHELL_PATH\" -c '
>  		GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) &&
>  		git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ &&
>  		git pack-objects --stdout >/dev/null < tmp.\$\$

Hmm, shouldn't we also be quoting '$' in front of SHELL_PATH to make the
test_expect_success interpolate the value of SHELL_PATH, instead of hoping
that SHELL_PATH does not have double-quote in it when the shell that forms
parameters given to test_expect_success interpolates it?

```

## Junio C Hamano, 2011-08-30 20:27

Subject: Re: [PATCH] t6030: use $SHELL_PATH to invoke user's preferred shell instead of bare sh
Message-ID: <7vaaaq1w6x.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vaaaq1w6x.fsf%40alter.siamese.dyndns.org
In-Reply-To: <7vfwki1wqo.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

>> +	git bisect run \"$SHELL_PATH\" -c '
>>  		GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) &&
>>  		git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ &&
>>  		git pack-objects --stdout >/dev/null < tmp.\$\$
>
> Hmm, shouldn't we also be quoting '$' in front of SHELL_PATH to make the
> test_expect_success interpolate the value of SHELL_PATH, instead of hoping
> that SHELL_PATH does not have double-quote in it when the shell that forms
> parameters given to test_expect_success interpolates it?

By doing this silly thing:

	$ mkdir '/var/tmp/a"b c/'
        $ ln -s /bin/sh '/var/tmp/a"b c/shell'

and then adding

	SHELL_PATH='/var/tmp/a"b c/shell'

after we source "test-lib.sh" in t6030, I see this breaks when the shell
parses to figure out what parameters to call test_expect_success with.

 t/t6030-bisect-porcelain.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 68c0e97..cd9de63 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -701,7 +701,7 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' "
 	git bisect reset &&
 	git checkout broken &&
 	git bisect start broken master --no-checkout &&
-	git bisect run \"$SHELL_PATH\" -c '
+	git bisect run \"\$SHELL_PATH\" -c '
 		GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) &&
 		git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ &&
 		git pack-objects --stdout >/dev/null < tmp.\$\$

```

## Brandon Casey, 2011-08-30 20:55

Subject: Re: [PATCH] t6030: use $SHELL_PATH to invoke user's preferred shell instead of bare sh
Message-ID: <9Mf0-hbcq2yQhZea9SPcW_u7qYq8G669j-m6nWbGmCA50MnYbUc0VyfjRoRkKCY9LZKWWqwZZVQfQlC6f2mFgdGd1OG7z0-ILDeRZolzPpA@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/9Mf0-hbcq2yQhZea9SPcW_u7qYq8G669j-m6nWbGmCA50MnYbUc0VyfjRoRkKCY9LZKWWqwZZVQfQlC6f2mFgdGd1OG7z0-ILDeRZolzPpA%40cipher.nrlssc.navy.mil
In-Reply-To: <7vaaaq1w6x.fsf@alter.siamese.dyndns.org>

```
On 08/30/2011 03:27 PM, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
>>> +	git bisect run \"$SHELL_PATH\" -c '
>>>  		GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) &&
>>>  		git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ &&
>>>  		git pack-objects --stdout >/dev/null < tmp.\$\$
>>
>> Hmm, shouldn't we also be quoting '$' in front of SHELL_PATH to make the
>> test_expect_success interpolate the value of SHELL_PATH, instead of hoping
>> that SHELL_PATH does not have double-quote in it when the shell that forms
>> parameters given to test_expect_success interpolates it?

Yep, makes sense.  Good catch.  Thanks.

-Brandon


> By doing this silly thing:
> 
> 	$ mkdir '/var/tmp/a"b c/'
>         $ ln -s /bin/sh '/var/tmp/a"b c/shell'
> 
> and then adding
> 
> 	SHELL_PATH='/var/tmp/a"b c/shell'
> 
> after we source "test-lib.sh" in t6030, I see this breaks when the shell
> parses to figure out what parameters to call test_expect_success with.
> 
>  t/t6030-bisect-porcelain.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> index 68c0e97..cd9de63 100755
> --- a/t/t6030-bisect-porcelain.sh
> +++ b/t/t6030-bisect-porcelain.sh
> @@ -701,7 +701,7 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' "
>  	git bisect reset &&
>  	git checkout broken &&
>  	git bisect start broken master --no-checkout &&
> -	git bisect run \"$SHELL_PATH\" -c '
> +	git bisect run \"\$SHELL_PATH\" -c '
>  		GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) &&
>  		git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ &&
>  		git pack-objects --stdout >/dev/null < tmp.\$\$

```
