# [PATCH] t0003: properly quote $HOME

8 messages from 2010-10-17 to 2010-10-18. Participants: Thomas Rast, Jonathan Nieder, Matthieu Moy, Johannes Sixt, Junio C Hamano.
Thread: https://gitlist.dev/t/25462

## Thomas Rast, 2010-10-17 19:13

Subject: [PATCH] t0003: properly quote $HOME
Message-ID: <decc39532e1706c50964bad14c51d0bcd9ab09a6.1287342744.git.trast@student.ethz.ch>
URL: https://gitlist.dev/e/decc39532e1706c50964bad14c51d0bcd9ab09a6.1287342744.git.trast%40student.ethz.ch

```
6df42ab (Add global and system-wide gitattributes, 2010-09-01) forgot
to quote one instance of $HOME in the tests.  This broke the test for
me with the shell complaining about an ambiguous redirect (but only
when run with --root for some reason).

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 t/t0003-attributes.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 25205ac..e75153b 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -38,7 +38,7 @@ test_expect_success 'setup' '
 	) >a/b/.gitattributes
 	(
 		echo "global test=global"
-	) >$HOME/global-gitattributes
+	) >"$HOME"/global-gitattributes
 
 '
 
-- 
1.7.3.1.266.g3c065

```

## Jonathan Nieder, 2010-10-17 19:18

Subject: Re: [PATCH] t0003: properly quote $HOME
Message-ID: <20101017191827.GD3202@burratino>
URL: https://gitlist.dev/e/20101017191827.GD3202%40burratino
In-Reply-To: <decc39532e1706c50964bad14c51d0bcd9ab09a6.1287342744.git.trast@student.ethz.ch>

```
Thomas Rast wrote:

> 6df42ab (Add global and system-wide gitattributes, 2010-09-01) forgot
> to quote one instance of $HOME in the tests.  This broke the test for
> me with the shell complaining about an ambiguous redirect (but only
> when run with --root for some reason).

Thanks.  What shell do you use?

IIRC it is not ambiguous according to POSIX but since e.g. OpenBSD
complains it is worth fixing.

```

## Thomas Rast, 2010-10-17 19:34

Subject: Re: [PATCH] t0003: properly quote $HOME
Message-ID: <201010172134.43983.trast@student.ethz.ch>
URL: https://gitlist.dev/e/201010172134.43983.trast%40student.ethz.ch
In-Reply-To: <20101017191827.GD3202@burratino>

```
Jonathan Nieder wrote:
> Thomas Rast wrote:
> 
> > 6df42ab (Add global and system-wide gitattributes, 2010-09-01) forgot
> > to quote one instance of $HOME in the tests.  This broke the test for
> > me with the shell complaining about an ambiguous redirect (but only
> > when run with --root for some reason).
> 
> Thanks.  What shell do you use?
> 
> IIRC it is not ambiguous according to POSIX but since e.g. OpenBSD
> complains it is worth fixing.

Oh, huh, so much for the theory that it's --root causing it:

  $ sh ./t0003-attributes.sh -q
  # passed all 8 test(s)
  1..8
  $ dash ./t0003-attributes.sh -q
  # passed all 8 test(s)
  1..8
  $ bash ./t0003-attributes.sh -q
  not ok - 1 setup
[...]
  $ bash --version
  GNU bash, version 4.1.7(1)-release (x86_64-suse-linux-gnu)
[...]

Then again, so much for your theory that it's only OpenBSD... ;-)

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```

## Matthieu Moy, 2010-10-17 19:37

Subject: Re: [PATCH] t0003: properly quote $HOME
Message-ID: <vpqiq10a9vu.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqiq10a9vu.fsf%40bauges.imag.fr
In-Reply-To: <decc39532e1706c50964bad14c51d0bcd9ab09a6.1287342744.git.trast@student.ethz.ch>

```
Thomas Rast <trast@student.ethz.ch> writes:

> 6df42ab (Add global and system-wide gitattributes, 2010-09-01) forgot
> to quote one instance of $HOME in the tests.  This broke the test for
> me with the shell complaining about an ambiguous redirect (but only
> when run with --root for some reason).

My bad, sorry. ACK for the fix.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Johannes Sixt, 2010-10-17 21:03

Subject: Re: [PATCH] t0003: properly quote $HOME
Message-ID: <201010172303.58780.j6t@kdbg.org>
URL: https://gitlist.dev/e/201010172303.58780.j6t%40kdbg.org
In-Reply-To: <decc39532e1706c50964bad14c51d0bcd9ab09a6.1287342744.git.trast@student.ethz.ch>

```
On Sonntag, 17. Oktober 2010, Thomas Rast wrote:
> 6df42ab (Add global and system-wide gitattributes, 2010-09-01) forgot
> to quote one instance of $HOME in the tests.  This broke the test for
> me with the shell complaining about an ambiguous redirect (but only
> when run with --root for some reason).
>
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
> ---
>  t/t0003-attributes.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
> index 25205ac..e75153b 100755
> --- a/t/t0003-attributes.sh
> +++ b/t/t0003-attributes.sh
> @@ -38,7 +38,7 @@ test_expect_success 'setup' '
>  	) >a/b/.gitattributes
>  	(
>  		echo "global test=global"
> -	) >$HOME/global-gitattributes
> +	) >"$HOME"/global-gitattributes
>
>  '

FWIW, the failure is due to bash trying to be helpful. Variable expansions 
after redirections are not word-split, but bash incorrectly detects 
an "ambiguous redirect" if the expanded text contains IFS characters. Your 
fix is of course the right way to work it around. But you might update the 
commit message.

-- Hannes

```

## Thomas Rast, 2010-10-18 09:09

Subject: [PATCH v2] t0003: properly quote $HOME
Message-ID: <b280c19ddc25f2f3a76d1871ed79906663daa802.1287392872.git.trast@student.ethz.ch>
URL: https://gitlist.dev/e/b280c19ddc25f2f3a76d1871ed79906663daa802.1287392872.git.trast%40student.ethz.ch
In-Reply-To: <201010172134.43983.trast@student.ethz.ch>

```
6df42ab (Add global and system-wide gitattributes, 2010-09-01) forgot
to quote one instance of $HOME in the tests.  This would be valid
according to POSIX, but bash 4 helpfully declines to execute the
command in question with an "ambiguous redirection" error.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

Changed the commit message to state the actual reason.

 t/t0003-attributes.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 25205ac..e75153b 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -38,7 +38,7 @@ test_expect_success 'setup' '
 	) >a/b/.gitattributes
 	(
 		echo "global test=global"
-	) >$HOME/global-gitattributes
+	) >"$HOME"/global-gitattributes
 
 '
 
-- 
1.7.3.1.270.gbc760

```

## Jonathan Nieder, 2010-10-18 10:02

Subject: Re: [PATCH v2] t0003: properly quote $HOME
Message-ID: <20101018100237.GB5641@burratino>
URL: https://gitlist.dev/e/20101018100237.GB5641%40burratino
In-Reply-To: <b280c19ddc25f2f3a76d1871ed79906663daa802.1287392872.git.trast@student.ethz.ch>

```
Thomas Rast wrote:

>                                               This would be valid
> according to POSIX, but bash 4 helpfully declines to execute the
> command in question with an "ambiguous redirection" error.

For the benefit of those wondering why they never saw this problem,
even after using bash for a while: bash in POSIX mode (e.g. when
running as "sh") does not have the same problem.

Presumably that's why this problem was not noticed until on a platform
without bash as /bin/sh, in v1.7.0-rc1~30 (work around an obnoxious
bash "safety feature" on OpenBSD, 2010-01-26).

I still like the patch. :)

```

## Junio C Hamano, 2010-10-18 19:15

Subject: Re: [PATCH] t0003: properly quote $HOME
Message-ID: <7veibn48j1.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7veibn48j1.fsf%40alter.siamese.dyndns.org
In-Reply-To: <decc39532e1706c50964bad14c51d0bcd9ab09a6.1287342744.git.trast@student.ethz.ch>

```
Thomas Rast <trast@student.ethz.ch> writes:

> 6df42ab (Add global and system-wide gitattributes, 2010-09-01) forgot
> to quote one instance of $HOME in the tests.  This broke the test for
> me with the shell complaining about an ambiguous redirect (but only
> when run with --root for some reason).

Sounds like a similar breakage to what was fixed in 3fa7c3d (work around
an obnoxious bash "safety feature" on OpenBSD, 2010-01-26) to me.

Thanks.

```
