]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Document a bug in GNU Bash with compound commands and redirections.
authorBenoit Sigoure <tsuna@lrde.epita.fr>
Fri, 2 Nov 2007 20:57:30 +0000 (21:57 +0100)
committerEric Blake <ebb9@byu.net>
Sat, 3 Nov 2007 16:59:29 +0000 (10:59 -0600)
* 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 <tsuna@lrde.epita.fr>
Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/autoconf.texi

index a98e2103bfd70e8710e2d0e4ea1cf9a20ac46b8c..325603f19e631ef0b2e1968cc5635714292a4e95 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-11-02  Benoit Sigoure  <tsuna@lrde.epita.fr>
+       and Jim Meyering  <meyering@redhat.com>
+       and Andreas Schwab <schwab@suse.de>
+       and Eric Blake  <ebb9@byu.net>
+
+       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  <ebb9@byu.net>
 
        Support m4 1.4.5 in testsuite.
index 73077a03206a2769021b7ca3febc6a770872f85e..2b20548253c722f82ec4ae628c324f0edf01c32e 100644 (file)
@@ -13507,6 +13507,7 @@ the @samp{x} into account later in the pipe.
 
 @table @asis
 @item @command{.}
+@c --------------
 @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{!}
+@c --------------
 @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
 
+
+@item @command{@{...@}}
+@c --------------------
+@prindex @command{@{...@}}
+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 @{...@}, but also affects
+other compound commands.
+
+@example
+$ @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
+@end example
+
+The workaround is simple: prime bash with a simple command before any
+compound command with redirection.
+
+@example
+$ @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
+@end example
+
+
 @item @command{break}
 @c ------------------
 @prindex @command{break}