autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Document a bug in GNU Bash with {...} blocks and redirection


From: Eric Blake
Subject: Re: [PATCH] Document a bug in GNU Bash with {...} blocks and redirections.
Date: Sat, 03 Nov 2007 09:40:34 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Benoit Sigoure on 11/2/2007 2:57 PM:
>       * doc/autoconf.texi (Limitations of Builtins): Mention that GNU Bash
>       doesn't properly set $? when `{ ... } >/bad' fails.
>       (Use re-wording from Jim Meyering)

I'm proposing the following, which starts from your patch, but also
incorporates the additional issues with other compound commands discovered
by Jim, and the workaround discovered by Andreas (weird - a patch with
more contributors than lines describing the change :)

Any more edits before we check this in?

2007-11-02  Benoit Sigoure  <address@hidden>
        and Jim Meyering  <address@hidden>
        and Andreas Schwab <address@hidden>
        and Eric Blake  <address@hidden>

        Document a bug in GNU Bash with {...} blocks and redirections.
        * doc/autoconf.texi (Limitations of Builtins): Mention that GNU
        Bash doesn't properly set $? when `{ ... } >/bad' fails, and give
        workaround.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHLJZy84KuGfSFAYARAiB+AKC+fCSyam8AaRoZxvH2oxw/811TcwCdGlu1
p7lPP3jbDHtj3Kj1+9MlrPM=
=ZVRV
-----END PGP SIGNATURE-----
>From 84aab2e342f234100bcba8eeaf2965fd002562bb Mon Sep 17 00:00:00 2001
From: Benoit Sigoure <address@hidden>
Date: Fri, 2 Nov 2007 21:57:30 +0100
Subject: [PATCH] Document a bug in GNU Bash with compound commands and 
redirections.

* doc/autoconf.texi (Limitations of Builtins): Mention that GNU
Bash doesn't properly set $? when `{ ... } >/bad' fails, and give
workaround.

Signed-off-by: Benoit Sigoure <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog         |   10 ++++++++++
 doc/autoconf.texi |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a98e210..325603f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-11-02  Benoit Sigoure  <address@hidden>
+       and Jim Meyering  <address@hidden>
+       and Andreas Schwab <address@hidden>
+       and Eric Blake  <address@hidden>
+
+       Document a bug in GNU Bash with compound commands and redirections.
+       * doc/autoconf.texi (Limitations of Builtins): Mention that GNU
+       Bash doesn't properly set $? when `{ ... } >/bad' fails, and give
+       workaround.
+
 2007-11-03  Eric Blake  <address@hidden>
 
        Support m4 1.4.5 in testsuite.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 73077a0..7d97a7f 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -13507,6 +13507,7 @@ the @samp{x} into account later in the pipe.
 
 @table @asis
 @item @command{.}
address@hidden --------------
 @prindex @command{.}
 Use @command{.} only with regular files (use @samp{test -f}).  Bash
 2.03, for instance, chokes on @samp{. /dev/null}.  Also, remember that
@@ -13515,6 +13516,7 @@ you want to use @command{.} on a file @file{foo} in the 
current
 directory, you must use @samp{. ./foo}.
 
 @item @command{!}
address@hidden --------------
 @prindex @command{!}
 The Unix version 7 shell did not support
 negating the exit status of commands with @command{!}, and this feature
@@ -13541,6 +13543,38 @@ More generally, one can always rewrite @samp{! 
@var{command}} as:
 if @var{command}; then (exit 1); else :; fi
 @end example
 
+
address@hidden @address@hidden@}}
address@hidden --------------------
address@hidden @address@hidden@}}
+As recently as GNU Bash 3.2, some shells do not properly set @samp{$?}
+when failing to write redirected output of any compound command other
+than a subshell group, when that compound command is the first thing
+executed.  This is most commonly observed with @address@hidden, but affects
+other compound commands.
+
address@hidden
+$ @kbd{bash -c '@{ echo foo; @} >/bad; echo $?'}
+bash: line 1: /bad: Permission denied
+0
+$ @kbd{bash -c 'while :; do echo; done >/bad; echo $?'}
+bash: line 1: /bad: Permission denied
+0
address@hidden example
+
+The workaround is simple - prime bash with a simple command before any
+compound command with redirection.
+
address@hidden
+$ @kbd{bash -c ':; @{ echo foo; @} >/bad; echo $?'}
+bash: line 1: /bad: Permission denied
+1
+$ @kbd{bash -c ':; while :; do echo; done >/bad; echo $?'}
+bash: line 1: /bad: Permission denied
+1
address@hidden example
+
+
 @item @command{break}
 @c ------------------
 @prindex @command{break}
-- 
1.5.3.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]