From: Ralf Wildenhues Date: Tue, 2 Mar 2010 06:48:42 +0000 (+0100) Subject: Fix Autotest tracing of shell pipelines for FreeBSD sh. X-Git-Tag: v2.66~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=475ccc750cef2b2f8d3f11757d672e9fcc18f0b5;p=thirdparty%2Fautoconf.git Fix Autotest tracing of shell pipelines for FreeBSD sh. * lib/autotest/general.m4 (_AT_DECIDE_TRACEABLE): Do not trace commands that contain [^|]|[^|], a likely shell pipeline. * tests/local.at (_AT_CHECK_ENV): Turn off tracing for egrep | grep pipeline. * doc/autoconf.texi (File Descriptors): Document limitation. * tests/autotest.at (Trace output): New test. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index 523628e8..3be2d1cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-03-02 Ralf Wildenhues + + Fix Autotest tracing of shell pipelines for FreeBSD sh. + * lib/autotest/general.m4 (_AT_DECIDE_TRACEABLE): Do not trace + commands that contain [^|]|[^|], a likely shell pipeline. + * tests/local.at (_AT_CHECK_ENV): Turn off tracing for egrep | + grep pipeline. + * doc/autoconf.texi (File Descriptors): Document limitation. + * tests/autotest.at (Trace output): New test. + 2010-03-01 Eric Blake Update file flow diagram to mention Automake. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 191a3979..04c8e91f 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -14785,6 +14785,9 @@ must be done @emph{inside} the command substitution. When running @samp{: `cd /zorglub` 2>/dev/null} expect the error message to escape, while @samp{: `cd /zorglub 2>/dev/null`} works properly. +FreeBSD 6.2 sh may mix the trace output lines from the statements in a +shell pipeline. + It is worth noting that Zsh (but not Ash nor Bash) makes it possible in assignments though: @samp{foo=`cd /zorglub` 2>/dev/null}. diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index 71e3090a..79421645 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -2034,6 +2034,8 @@ m4_cond([m4_eval(m4_index([$1], [`]) >= 0)], [1], [[a ${...} parameter expansion]], [m4_eval(m4_index([$1], m4_newline) >= 0)], [1], [[an embedded newline]], + [m4_eval(m4_bregexp([$1], [[^|]|[^|]]) >= 0)], [1], + [[a shell pipeline]], []))]dnl No reason. [m4_if(m4_index(_m4_defn([at_reason]), [a]), [0],]dnl dnl We know at build time that tracing COMMANDS is never safe. diff --git a/tests/autotest.at b/tests/autotest.at index 8a088970..88078ace 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -349,6 +349,12 @@ AT_CHECK_AT_TEST([unquoted output], [${a}"`echo 'b '`\`\backtick]m4_newline)], [], [], [], [], [AT_KEYWORDS([AT@&t@_CHECK_UNQUOTED])]) +AT_CHECK_AT_TEST([Trace output], + [AT_CHECK([echo some longer longer longer command piped | ]dnl + [sed 's,into some other longer longer longer command,,'], + [], [some longer longer longer command piped +])]) + AT_CHECK_AT([Logging], [[AT_INIT([artificial test suite]) dnl intentionally write failing tests, to see what gets logged diff --git a/tests/local.at b/tests/local.at index dcfdf608..c26d0713 100644 --- a/tests/local.at +++ b/tests/local.at @@ -243,6 +243,9 @@ m4_define([AT_CHECK_CONFIGURE], # In this case just don't pay attention to the env. It would be great # to keep the error message but we can't: that would break AT_CHECK. # +# FreeBSD sh may intermingle the trace output from the egrep and grep +# commands in the pipe, so turn off tracing for these. +# # Some tests might exit prematurely when they find a problem, in # which case `env-after' is probably missing. Don't check it then. # @@ -287,6 +290,7 @@ test -f state-ls.after \ && { $at_diff state-ls.before state-ls.after || return 1; } # Compare variable space dumps. if test -f state-env.before && test -f state-env.after; then + set +x for act_file in state-env.before state-env.after do $EGREP -v '^(m4_join([|], @@ -316,6 +320,7 @@ if test -f state-env.before && test -f state-env.after; then # There may be variables spread on several lines; remove latter lines. $GREP '^m4_defn([m4_re_word])=' >clean-$act_file done + $at_traceon $at_diff clean-state-env.before clean-state-env.after fi } [#]at_check_env])