From: Eric Blake Date: Thu, 23 Apr 2009 04:06:04 +0000 (-0600) Subject: Fix quoting of m4 macros in AT_CHECK. X-Git-Tag: v2.64~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bec0c1d32f56cfec6a9c78ddbed658b03863ae6;p=thirdparty%2Fautoconf.git Fix quoting of m4 macros in AT_CHECK. * lib/autotest/general.m4 (AT_CHECK): Expand prior to adding escapes, to avoid shell syntax errors caused by late macro expansion. * NEWS: Document this change. * tests/autotest.at (Metacharacters in command from M4 expansion): New test. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 5d3c45c85..0c243cadf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2009-04-24 Eric Blake + Fix quoting of m4 macros in AT_CHECK. + * lib/autotest/general.m4 (AT_CHECK): Expand prior to adding + escapes, to avoid shell syntax errors caused by late macro + expansion. + * NEWS: Document this change. + * tests/autotest.at (Metacharacters in command from M4 expansion): + New test. + manual: Use consistent spelling of here-document. * doc/autoconf.texi (Defining Symbols, Programming in M4sh) (Common Shell Constructs, Macro Names, Writing Testsuites): Fix diff --git a/NEWS b/NEWS index 2831d664d..11466d6a9 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ GNU Autoconf NEWS - User visible changes. ** Ensure AT_CHECK can support commands that include a # given with proper m4 quoting. For shell comments, this is a new feature; for non-shell comments, this fixes a regression introduced in 2.63b. + Additionally, AT_CHECK correctly supplies shell escapes for + metacharacters occurring in m4 macro expansions within the expected + stdout and stderr parameters. ** The macro AT_CHECK now understands the concept of hard failure. If a test exits with an unexpected status 99, cleanup actions for the diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index a16224b89..ce653978d 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -1901,8 +1901,8 @@ $2[]_ATEOF # This may cause spurious failures when the test suite is run with `-x'. # _AT_DEFINE_SETUP([AT_CHECK], -[_AT_CHECK(m4_expand([$1]), [$2], m4_expand([AS_ESCAPE([$3])]), - m4_expand([AS_ESCAPE([$4])]), [$5], [$6])]) +[_AT_CHECK(m4_expand([$1]), [$2], AS_ESCAPE(m4_dquote(m4_expand([$3]))), + AS_ESCAPE(m4_dquote(m4_expand([$4]))), [$5], [$6])]) # AT_CHECK_UNQUOTED(COMMANDS, [STATUS = 0], STDOUT, STDERR, # [RUN-IF-FAIL], [RUN-IF-PASS]) diff --git a/tests/autotest.at b/tests/autotest.at index 0fad78db6..d86088c6f 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -491,6 +491,12 @@ bar']) ]], [])]) +AT_CHECK_AT_TEST([Metacharacters in command from M4 expansion], + [m4_define([GNU], [\"`]) + AT_CHECK([echo '\"`' [GNU] 'GNU'], 0, [GNU [G][NU] [\"` +]], [])]) + + ## -------------------------------------- ## ## Backslash- in test commands. ## ## -------------------------------------- ##