[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
minor improvements for {...} problem; also, prefer && to ;
From: |
Paul Eggert |
Subject: |
minor improvements for {...} problem; also, prefer && to ; |
Date: |
Fri, 09 Nov 2007 00:47:06 -0800 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
I installed this:
2007-11-09 Paul Eggert <address@hidden>
* doc/autoconf.texi (Limitations of Builtins): Document problem
with { ... } a bit more clearly. Suggest ":;{" as a shorthand
for the workaround.
* lib/m4sugar/Makefile.am (version.m4): Detect 'echo' failure.
Use ":;{" shorthand.
* tests/Makefile.am ($(srcdir)/package.m4): Likewise.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 421056e..1dcd60b 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -13564,11 +13564,10 @@ if @var{command}; then (exit 1); else :; fi
@item @address@hidden@}}
@c --------------------
@prindex @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 also
affects
-other compound commands.
+Bash 3.2 and earlier sometimes does not properly set @samp{$?} when
+failing to write redirected output of a compound command. This problem
+is most commonly observed with @address@hidden@address@hidden; it does not
occur
+with @samp{(@dots{})}. For example:
@example
$ @kbd{bash -c '@{ echo foo; @} >/bad; echo $?'}
@@ -13579,14 +13578,10 @@ 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.
+To work around the bug, prepend @samp{:;}:
@example
-$ @kbd{bash -c ':; @{ echo foo; @} >/bad; echo $?'}
-bash: line 1: /bad: Permission denied
-1
-$ @kbd{bash -c ':; while :; do echo; done >/bad; echo $?'}
+$ @kbd{bash -c ':;@{ echo foo; @} >/bad; echo $?'}
bash: line 1: /bad: Permission denied
1
@end example
diff --git a/lib/m4sugar/Makefile.am b/lib/m4sugar/Makefile.am
index de32907..7360ca1 100644
--- a/lib/m4sugar/Makefile.am
+++ b/lib/m4sugar/Makefile.am
@@ -26,17 +26,16 @@ CLEANFILES = $(nodist_m4sugarlib_DATA)
# The `:;' works around a redirected compound command bash exit status bug.
version.m4: $(top_srcdir)/configure.ac
- :; \
- { \
- echo '# This file is part of -*- Autoconf -*-.'; \
- echo '# Version of Autoconf.'; \
- echo '# Copyright (C) 1999, 2000, 2001, 2002, 2006, 2007'; \
- echo '# Free Software Foundation, Inc.'; \
- echo ;\
- echo 'm4_define([m4_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \
- echo 'm4_define([m4_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])'; \
- echo 'm4_define([m4_PACKAGE_VERSION], [$(PACKAGE_VERSION)])'; \
- echo 'm4_define([m4_PACKAGE_STRING], [$(PACKAGE_STRING)])'; \
+ :;{ \
+ echo '# This file is part of -*- Autoconf -*-.' && \
+ echo '# Version of Autoconf.' && \
+ echo '# Copyright (C) 1999, 2000, 2001, 2002, 2006, 2007' && \
+ echo '# Free Software Foundation, Inc.' && \
+ echo &&\
+ echo 'm4_define([m4_PACKAGE_NAME], [$(PACKAGE_NAME)])' && \
+ echo 'm4_define([m4_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])' && \
+ echo 'm4_define([m4_PACKAGE_VERSION], [$(PACKAGE_VERSION)])' && \
+ echo 'm4_define([m4_PACKAGE_STRING], [$(PACKAGE_STRING)])' && \
echo 'm4_define([m4_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \
} >version.m4
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ed129fd..45267ff 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -34,15 +34,14 @@ include ../lib/freeze.mk
## package.m4. ##
## ------------ ##
-# The `:;' works around a redirected compound command bash exit status bug.
+# The `:;' works around a Bash 3.2 bug when the output is not writeable.
$(srcdir)/package.m4: Makefile
- :; \
- { \
- echo '# Signature of the current package.'; \
- echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \
- echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])'; \
- echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])'; \
- echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])'; \
+ :;{ \
+ echo '# Signature of the current package.' && \
+ echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])' && \
+ echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])' && \
+ echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])' && \
+ echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])' && \
echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \
} >$(srcdir)/package.m4
- minor improvements for {...} problem; also, prefer && to ;,
Paul Eggert <=