Subject: Re: bug#10465: MSYS read-only file trouble

From: Peter Rosin <[email-masked]>
Date: Mon, 09 Jan 2012 23:42:22 +0100

Peter Rosin skrev 2012-01-09 23:14:
> Stefano Lattarini skrev 2012-01-09 20:52:
>> On 01/09/2012 08:11 PM, Peter Rosin wrote:
>>> Stefano Lattarini skrev 2012-01-09 20:03:
>>>>> + ./tap-driver --test-name zardoz --log-file zardoz.log --trs-file zardoz.trs -- sh -c 'echo 1..1; echo ok 1; echo "Hello, World!"'
>>>>> + st=1
>>>>>
>>>> Hmmm... looks like the shell is not returning a non-zero exit status in
>>>> face of a I/O redirection failure.
>>>>
>>>> Could you try what happens doing the following?
>>>>
>>>>   $ > foo; chmod a-w foo; sh -c ': > foo; echo one: $?'; echo two: $?
>>>
>>> sh: foo: Permission denied
>>> two: 1
>>>
>> So the shell catches the redirection error correctly after all.  Hmmm.
>>
>> Is the failure of tap-driver-stderr.test reproducible?
> 
> Yes, fails in the same way every time.

FWIW, this "fixes" it, but I don't actually know why a subshell would
make a difference?

$ sh --version
GNU bash, version 3.1.17(1)-release (i686-pc-msys)
Copyright (C) 2005 Free Software Foundation, Inc.

Cheers,
Peter

>From c0bc106cbbd40225cd761124adaf434c004ad269 Mon Sep 17 00:00:00 2001
From: Peter Rosin <[email-masked]>
Date: Mon, 9 Jan 2012 23:40:45 +0100
Subject: [PATCH] tap/awk: run the awk program in a subshell

MSYS bash (3.1.17) apparently has problems with the exit status of a
grouping without a subshell.

Fixes automake bug#10465.

* lib/tap-driver.sh: Use a full blown subshell for running the awk script.
---
 lib/tap-driver.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh
index c011298..6e9df79 100755
--- a/lib/tap-driver.sh
+++ b/lib/tap-driver.sh
@@ -115,7 +115,7 @@ else
   init_colors=''
 fi
 
-{
+(
   (
     # Ignore common signals (in this subshell only!), to avoid potential
     # problems with Korn shells.  Some Korn shells are known to propagate
@@ -634,7 +634,7 @@ exit 0
 '
 
 # TODO: document that we consume the file descriptor 3 :-(
-} 3>"$log_file"
+) 3>"$log_file"
 
 test $? -eq 0 || fatal "I/O or internal error"
 
-- 
1.7.5.1