diff options
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | lib/m4sugar/m4sh.m4 | 28 | ||||
-rw-r--r-- | tests/m4sh.at | 74 |
3 files changed, 103 insertions, 5 deletions
@@ -17,9 +17,13 @@ GNU Autoconf NEWS - User visible changes. by autoreconf. ** Use of printf is now recommended instead of working around bugs in - echo. Macros AS_ECHO and AS_ECHO_N now expand unconditionally to + echo. The macros AS_ECHO and AS_ECHO_N now expand unconditionally to 'printf "%s\n"' and 'printf %s'. +** Use of the undocumented internal shell variables $as_echo and + $as_echo_n now elicits a warning in the 'obsolete' category. + The macros AS_ECHO and AS_ECHO_N should be used instead. + ** AC_CHECK_HEADER and AC_CHECK_HEADERS now default to doing only a compilation test. This completes the transition from preprocessor- based header tests begun in Autoconf 2.56. diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 4af31517..af286857 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -813,8 +813,11 @@ m4_defun_init([_AS_ECHO_LOG], # in a command substitution prints only the first character of the output # with ksh version M-11/16/88f on AIX 6.1; it needs to be reset by another # backquoted echo. -m4_defun([_AS_ECHO_N_PREPARE], -[ECHO_C= ECHO_N= ECHO_T= +m4_defun([_AS_ECHO_N_PREPARE], [ +# Determine whether it's possible to make 'echo' print without a newline. +# These variables are no longer used directly by Autoconf, but are AC_SUBSTed +# for compatibility with existing Makefiles. +ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in @%:@((((( -n*) case `echo 'xy\c'` in @@ -826,6 +829,13 @@ case `echo -n x` in @%:@((((( *) ECHO_N='-n';; esac + +# For backward compatibility with old third-party macros, we provide +# the shell variables $as_echo and $as_echo_n. New code should use +# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. +dnl The @&t@ prevents a spurious deprecation diagnostic. +as_@&t@echo='printf %s\n' +as_@&t@echo_n='printf %s' ])# _AS_ECHO_N_PREPARE @@ -1032,16 +1042,26 @@ fi # Output WORD followed by a newline. WORD must be a single shell word # (typically a quoted string). The bytes of WORD are output as-is, even # if it starts with "-" or contains "\". -m4_defun([AS_ECHO], +m4_define([AS_ECHO], [printf "%s\n" $1]) +# Deprecation warning for the former internal shell variable $as_echo. +m4_define([as_echo], +[m4_warn([obsolete], + [$as_echo is obsolete; use AS_ECHO(["message"]) instead])as_@&t@echo]) + # AS_ECHO_N(WORD) # --------------- # Like AS_ECHO(WORD), except do not output the trailing newline. -m4_defun([AS_ECHO_N], +m4_define([AS_ECHO_N], [printf %s $1]) +# Deprecation warning for the former internal shell variable $as_echo_n. +m4_define([as_echo_n], +[m4_warn([obsolete], + [$as_echo_n is obsolete; use AS_ECHO_N(["message"]) instead])as_@&t@echo_n]) + # AS_TEST_X # --------- diff --git a/tests/m4sh.at b/tests/m4sh.at index 16a0f168..9fd84558 100644 --- a/tests/m4sh.at +++ b/tests/m4sh.at @@ -557,6 +557,80 @@ AT_CHECK([$CONFIG_SHELL ./script]) AT_CLEANUP +# Obsolete shell variables with the same functionality as above. +AT_SETUP([obsolete $as@&t@_echo and $as@&t@_echo_n]) +AT_KEYWORDS([m4sh]) + +AT_DATA_M4SH([script.as], +[[AS_INIT +AS_REQUIRE([_AS_ECHO_N_PREPARE]) + +m4_define([ECHO_TEST], +[echo=`$as_echo '$1'` +test "X$echo" = 'X$1' || + echo "\$as@&t@_echo '$1' outputs '$echo'" >&2 + +echo=`$as_echo_n '$1'` +test "X$echo" = 'X$1' || + echo "\$as@&t@_echo_n '$1' outputs '$echo'" >&2]) + +ECHO_TEST([-]) +ECHO_TEST([--]) +ECHO_TEST([---...---]) +ECHO_TEST([ ]) +ECHO_TEST([-e]) +ECHO_TEST([-E]) +ECHO_TEST([-n]) +ECHO_TEST([-n -n]) +ECHO_TEST([-e -n]) +ECHO_TEST([ab\ncd]) +ECHO_TEST([abcd\c]) +ECHO_TEST([\a\b\c\f\n\r\t\v\"\]) +ECHO_TEST([ab +cd +e]) +ECHO_TEST([ + ]) +ECHO_TEST([ +\c]) +AS_EXIT(0) +]]) + +AT_CHECK_M4SH([-Wobsolete], 0, [], +[[script.as:13: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:13: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:14: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:14: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:15: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:15: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:16: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:16: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:17: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:17: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:18: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:18: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:19: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:19: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:20: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:20: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:21: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:21: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:22: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:22: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:23: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:23: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:24: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:24: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:25: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:25: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:28: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:28: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +script.as:30: warning: $as@&t@_echo is obsolete; use AS@&t@_ECHO(["message"]) instead +script.as:30: warning: $as@&t@_echo_n is obsolete; use AS@&t@_ECHO_N(["message"]) instead +]]) +AT_CHECK([$CONFIG_SHELL ./script]) + +AT_CLEANUP ## ----------------- ## |