# [PATCH] Use SHELL_PATH as hash bang in test suite askpass helper script.

5 messages from 2014-09-28 to 2014-09-29. Participants: Ben Walton, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/37642

## Ben Walton, 2014-09-28 22:21

Subject: [PATCH] Use SHELL_PATH as hash bang in test suite askpass helper script.
Message-ID: <1411942867-3995-1-git-send-email-bdwalton@gmail.com>
URL: https://gitlist.dev/e/1411942867-3995-1-git-send-email-bdwalton%40gmail.com

```
The askpass script that is created for use by the test suite should
use SHELL_PATH for its hash bang instead of /bin/sh. Commit 5a4352024
introduced the use of idioms not supported in some legacy /bin/sh
implementations.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
---
 t/lib-credential.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/lib-credential.sh b/t/lib-credential.sh
index 9e7d796..ca4a6de 100755
--- a/t/lib-credential.sh
+++ b/t/lib-credential.sh
@@ -278,8 +278,8 @@ helper_test_timeout() {
 	'
 }
 
-cat >askpass <<\EOF
-#!/bin/sh
+echo "#!$SHELL_PATH" >askpass
+cat >>askpass <<\EOF
 echo >&2 askpass: $*
 what=$(echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z)
 echo "askpass-$what"
-- 
1.9.1

```

## Jeff King, 2014-09-28 23:14

Subject: Re: [PATCH] Use SHELL_PATH as hash bang in test suite askpass helper script.
Message-ID: <20140928231428.GA9061@peff.net>
URL: https://gitlist.dev/e/20140928231428.GA9061%40peff.net
In-Reply-To: <1411942867-3995-1-git-send-email-bdwalton@gmail.com>

```
On Sun, Sep 28, 2014 at 11:21:07PM +0100, Ben Walton wrote:

> The askpass script that is created for use by the test suite should
> use SHELL_PATH for its hash bang instead of /bin/sh. Commit 5a4352024
> introduced the use of idioms not supported in some legacy /bin/sh
> implementations.

Sounds good.

> -cat >askpass <<\EOF
> -#!/bin/sh
> +echo "#!$SHELL_PATH" >askpass
> +cat >>askpass <<\EOF

This can just become:

  write_script askpass <<\EOF

which handles this for us (and you can get rid of the manual chmod then,
too).

-Peff

```

## Ben Walton, 2014-09-29 07:02

Subject: [PATCH] Ensure SHELL_PATH is the hash bang for test suite askpass helper script.
Message-ID: <1411974127-5258-1-git-send-email-bdwalton@gmail.com>
URL: https://gitlist.dev/e/1411974127-5258-1-git-send-email-bdwalton%40gmail.com
In-Reply-To: <20140928231428.GA9061@peff.net>

```
The askpass script that is created for use by the test suite should
use SHELL_PATH for its hash bang instead of /bin/sh. Commit 5a4352024
introduced the use of idioms not supported in some legacy /bin/sh
implementations.

Use write_script to ensure this happens automatically. This lets us
remove the chmod step as well, since write_script handles that.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
---
 t/lib-credential.sh | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/t/lib-credential.sh b/t/lib-credential.sh
index 9e7d796..d8e41f7 100755
--- a/t/lib-credential.sh
+++ b/t/lib-credential.sh
@@ -278,12 +278,10 @@ helper_test_timeout() {
 	'
 }
 
-cat >askpass <<\EOF
-#!/bin/sh
+write_script askpass <<\EOF
 echo >&2 askpass: $*
 what=$(echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z)
 echo "askpass-$what"
 EOF
-chmod +x askpass
 GIT_ASKPASS="$PWD/askpass"
 export GIT_ASKPASS
-- 
1.9.1

```

## Jeff King, 2014-09-29 17:30

Subject: Re: [PATCH] Ensure SHELL_PATH is the hash bang for test suite askpass helper script.
Message-ID: <20140929173034.GA3845@peff.net>
URL: https://gitlist.dev/e/20140929173034.GA3845%40peff.net
In-Reply-To: <1411974127-5258-1-git-send-email-bdwalton@gmail.com>

```
On Mon, Sep 29, 2014 at 08:02:07AM +0100, Ben Walton wrote:

> The askpass script that is created for use by the test suite should
> use SHELL_PATH for its hash bang instead of /bin/sh. Commit 5a4352024
> introduced the use of idioms not supported in some legacy /bin/sh
> implementations.
> 
> Use write_script to ensure this happens automatically. This lets us
> remove the chmod step as well, since write_script handles that.
> 
> Signed-off-by: Ben Walton <bdwalton@gmail.com>

Thanks, this looks good to me.

-Peff

```

## Junio C Hamano, 2014-09-29 17:49

Subject: Re: [PATCH] Ensure SHELL_PATH is the hash bang for test suite askpass helper script.
Message-ID: <xmqq38bauxkg.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq38bauxkg.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1411974127-5258-1-git-send-email-bdwalton@gmail.com>

```
Ben Walton <bdwalton@gmail.com> writes:

> The askpass script that is created for use by the test suite should
> use SHELL_PATH for its hash bang instead of /bin/sh. Commit 5a4352024
> introduced the use of idioms not supported in some legacy /bin/sh
> implementations.
>
> Use write_script to ensure this happens automatically. This lets us
> remove the chmod step as well, since write_script handles that.
>
> Signed-off-by: Ben Walton <bdwalton@gmail.com>
> ---

I'll leave out the "some legacy shells we do not support want to use
`command`" from the justification of this change.  Use of the
write_script helper is the right thing to do---$SHELL_PATH points at
the shell the user told us s/he wants to use, and that is a reason
enough for this change.  The reason why the user wants to use that
shell is immaterial.

Thanks.


>  t/lib-credential.sh | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/t/lib-credential.sh b/t/lib-credential.sh
> index 9e7d796..d8e41f7 100755
> --- a/t/lib-credential.sh
> +++ b/t/lib-credential.sh
> @@ -278,12 +278,10 @@ helper_test_timeout() {
>  	'
>  }
>  
> -cat >askpass <<\EOF
> -#!/bin/sh
> +write_script askpass <<\EOF
>  echo >&2 askpass: $*
>  what=$(echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z)
>  echo "askpass-$what"
>  EOF
> -chmod +x askpass
>  GIT_ASKPASS="$PWD/askpass"
>  export GIT_ASKPASS

```
