Autoconf test failure caused by Bash bug with "{ ... } >unwritable"

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Autoconf test failure caused by Bash bug with "{ ... } >unwritable"

Paul Eggert
Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.8
Compiler: gcc -m64
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc' -DCONF_OSTYPE='solaris2.8' -DCONF_MACHTYPE='sparc-sun-solaris2.8' -DCONF_VENDOR='sun' -DLOCALEDIR='/usr/local/cs/bash-3.2/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DSOLARIS   -I.  -I. -I./include -I./lib   -g -O2
uname output: SunOS westholme 5.8 Generic_117350-49 sun4u sparc SUNW,Sun-Fire-280R
Machine Type: sparc-sun-solaris2.8

Bash Version: 3.2
Patch Level: 25
Release Status: release

Description:

        I'm following up on this thread:

        http://lists.gnu.org/archive/html/autoconf/2007-11/msg00007.html       

        which reported an Autoconf problem that we have tracked down to a bug
        in Bash.  The problem is that this command:

           bash -c '{ echo foo; } >unwriteable'

        exits with status 0.  We have a workaround, but the Bash bug should
        get fixed.

Repeat-By:

        $ touch foo
        $ chmod a-w foo
        $ bash -c '{ echo foo; } >foo'; echo $?
        bash: foo: Permission denied
        0

        The last line of output should be 1, not 0.

Fix:

2007-11-02  Paul Eggert  <[hidden email]>

        * execute_cmd.c (execute_command_internal): Consider a redirection
        failure to be a failure in the last compound command.
        * tests/redir7.sub: Test for this bug.

--- execute_cmd.c~ 2007-11-02 13:01:35.789664000 -0700
+++ execute_cmd.c 2007-11-02 14:44:51.401990000 -0700
@@ -614,7 +614,7 @@
       cleanup_redirects (redirection_undo_list);
       redirection_undo_list = (REDIRECT *)NULL;
       dispose_exec_redirects ();
-      return (EXECUTION_FAILURE);
+      return (last_command_exit_value = EXECUTION_FAILURE);
     }
 
   if (redirection_undo_list)
--- tests/redir7.sub~ 2005-10-11 13:00:28.000000000 -0700
+++ tests/redir7.sub 2007-11-02 14:39:02.220301200 -0700
@@ -67,3 +67,10 @@
 
 # fixed in bash-3.1
 echo 'exec <&3' | ${THIS_SH} 3<&0
+
+# fixed in bash-3.3
+if ${THIS_SH} -c '{ echo foo; } > /' 2>/dev/null; then
+  echo "bash -c '{ echo foo; } > /' succeeded, but it should fail."
+else
+  :
+fi