From 3bec0c1d32f56cfec6a9c78ddbed658b03863ae6 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 22 Apr 2009 22:06:04 -0600 Subject: [PATCH] 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 --- ChangeLog | 8 ++++++++ NEWS | 3 +++ lib/autotest/general.m4 | 4 ++-- tests/autotest.at | 6 ++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5d3c45c8..0c243cad 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 2831d664..11466d6a 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 a16224b8..ce653978 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 0fad78db..d86088c6 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. ## ## -------------------------------------- ## -- 2.11.4.GIT