threads / patch / 25114

patcht/t7300: workaround ancient touch by rearranging arguments

Subject: [PATCH] t/t7300: workaround ancient touch by rearranging arguments

## tl;dr

5 messages between Sep 15, 2010 and Sep 18, 2010. Diffs are folded; open one to read it.

replies: 4people: 4as markdown or json

Brandon Casey· Sep 15, 2010, 20:58 UTC · lore
From: Brandon Casey <drafnel@gmail.com>

The ancient touch on Solaris 7 thinks that a decimal number supplied as the first argument specifies a date_time to give to the files specified by the remaining arguments. In this case, it fails to parse '1' as a proper date_time and exits with a failure status. Workaround this flaw by rearranging the arguments supplied to touch so that a non-digit appears first and touch will not be confused.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t7300-clean.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to t/t7300-clean.sh +1 −1
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 7dbbea1..6c776e9 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -443,7 +443,7 @@ test_expect_success 'git clean -e' '
 	(
 		cd repo &&
 		git init &&
-		touch 1 2 3 known &&
+		touch known 1 2 3 &&
 		git add known &&
 		git clean -f -e 1 -e 2 &&
 		test -e 1 &&
-- 
1.7.2.1
Junio C Hamano· Sep 15, 2010, 22:08 UTC · re: Brandon Casey · lore

Re: [PATCH] t/t7300: workaround ancient touch by rearranging arguments

Brandon Casey <casey@nrlssc.navy.mil> writes:
Show 10 quoted lines
> From: Brandon Casey <drafnel@gmail.com>
>
> The ancient touch on Solaris 7 thinks that a decimal number supplied as
> the first argument specifies a date_time to give to the files specified by
> the remaining arguments.  In this case, it fails to parse '1' as a proper
> date_time and exits with a failure status.  Workaround this flaw by
> rearranging the arguments supplied to touch so that a non-digit appears
> first and touch will not be confused.
>
> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>

Yuck, there were other reasons why I tend to write ">file" in our tests, just to create a new and empty file, but I didn't remember seeing this one. It's been a while since I touched Solaris the last time.

Thanks for catching.
Show 18 quoted lines
>  t/t7300-clean.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
> index 7dbbea1..6c776e9 100755
> --- a/t/t7300-clean.sh
> +++ b/t/t7300-clean.sh
> @@ -443,7 +443,7 @@ test_expect_success 'git clean -e' '
>  	(
>  		cd repo &&
>  		git init &&
> -		touch 1 2 3 known &&
> +		touch known 1 2 3 &&
>  		git add known &&
>  		git clean -f -e 1 -e 2 &&
>  		test -e 1 &&
> -- 
> 1.7.2.1
Jeff King· Sep 16, 2010, 00:31 UTC · re: Brandon Casey · lore

Re: [PATCH] t/t7300: workaround ancient touch by rearranging arguments

On Wed, Sep 15, 2010 at 03:58:22PM -0500, Brandon Casey wrote:
Show 8 quoted lines
> From: Brandon Casey <drafnel@gmail.com>
> 
> The ancient touch on Solaris 7 thinks that a decimal number supplied as
> the first argument specifies a date_time to give to the files specified by
> the remaining arguments.  In this case, it fails to parse '1' as a proper
> date_time and exits with a failure status.  Workaround this flaw by
> rearranging the arguments supplied to touch so that a non-digit appears
> first and touch will not be confused.
Hmm, this seemed eerily familiar, and sure enough:
  http://article.gmane.org/gmane.comp.version-control.git/101270

I don't _think_ I had Solaris 7 anytime recently, so the issue may be even more widespread (I would guess that my patch was a result of Solaris 8). Anyway, good catch.

-Peff
Sverre Rabbelier· Sep 17, 2010, 23:26 UTC · re: Jeff King · lore

Re: [PATCH] t/t7300: workaround ancient touch by rearranging arguments

Heya,
On Thu, Sep 16, 2010 at 02:31, Jeff King <peff@peff.net> wrote:
> Hmm, this seemed eerily familiar, and sure enough:
>
>  http://article.gmane.org/gmane.comp.version-control.git/101270

Does this call for a git_touch which does a regular 'touch' for each of its arguments?

-- 
Cheers,

Sverre Rabbelier
Jeff King· Sep 18, 2010, 03:46 UTC · re: Sverre Rabbelier · lore

Re: [PATCH] t/t7300: workaround ancient touch by rearranging arguments

On Sat, Sep 18, 2010 at 01:26:25AM +0200, Sverre Rabbelier wrote:
Show 7 quoted lines
> On Thu, Sep 16, 2010 at 02:31, Jeff King <peff@peff.net> wrote:
> > Hmm, this seemed eerily familiar, and sure enough:
> >
> >  http://article.gmane.org/gmane.comp.version-control.git/101270
> 
> Does this call for a git_touch which does a regular 'touch' for each
> of its arguments?

I don't know the broken touch's behavior, and I don't have it handy. It might handle "touch 1" fine or it might interpret it as "touch at time 1, no file arguments". Brandon's solution is good enough for a test script.

If you really wanted a portable git_touch, you would spell it ">>$file".
-Peff

← back to recent threads