From: Ralf Wildenhues Date: Tue, 13 Nov 2007 07:30:58 +0000 (-0800) Subject: * doc/autoconf.texi (Making testsuite Scripts): Document X-Git-Tag: v2.62~141 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=610817462bbfcacab3df3b8ed678f7b4b31fe1ad;p=thirdparty%2Fautoconf.git * doc/autoconf.texi (Making testsuite Scripts): Document ":;{" shorthand as in previous patch. 2007-11-12 Paul Eggert * 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/ChangeLog b/ChangeLog index 6b95b48a..14262785 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-11-12 Ralf Wildenhues + + * doc/autoconf.texi (Making testsuite Scripts): Document + ":;{" shorthand as in previous patch. + +2007-11-12 Paul Eggert + + * 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. + 2007-11-12 Jim Meyering Add more non-srcdir build support. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index acc80cf4..8633fa2c 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -13572,11 +13572,10 @@ if @var{command}; then (exit 1); else :; fi @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. +Bash 3.2 (and earlier versions) sometimes does not properly set +@samp{$?} when failing to write redirected output of a compound command. +This problem is most commonly observed with @samp{@{@dots{}@}}; it does +not occur with @samp{(@dots{})}. For example: @example $ @kbd{bash -c '@{ echo foo; @} >/bad; echo $?'} @@ -13587,14 +13586,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 @@ -20239,13 +20234,14 @@ we suggest that you also define @code{AT_PACKAGE_NAME}, suggest the following makefile excerpt: @smallexample +# The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac - @{ \ - 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' @end smallexample diff --git a/lib/m4sugar/Makefile.am b/lib/m4sugar/Makefile.am index de329076..7360ca10 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 aa43da6b..4cf7fd10 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,13 +36,12 @@ include ../lib/freeze.mk # The `:;' works around a redirected compound command bash exit status bug. 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)])'; \ } > $@-t mv $@-t $@