From: Eric Blake Date: Thu, 13 Nov 2008 03:10:09 +0000 (-0700) Subject: Make M4sh, not autoconf, guarantee sane $SHELL. X-Git-Tag: v2.63b~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=973149e01473b0a96d8565cffe5846187f3f49aa;p=thirdparty%2Fautoconf.git Make M4sh, not autoconf, guarantee sane $SHELL. * lib/autoconf/general.m4 (_AC_INIT_DEFAULTS): Move setting of SHELL... * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): ...to here. * doc/autoconf.texi (Initialization Macros): Document the effect on SHELL. * tests/m4sh.at (AS@&t@_INIT_GENERATED): New test. Reported by Ralf Wildenhues. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 2a057487e..634412a32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-11-12 Eric Blake + + Make M4sh, not autoconf, guarantee sane $SHELL. + * lib/autoconf/general.m4 (_AC_INIT_DEFAULTS): Move setting of + SHELL... + * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): ...to here. + * doc/autoconf.texi (Initialization Macros): Document the effect + on SHELL. + * tests/m4sh.at (AS@&t@_INIT_GENERATED): New test. + Reported by Ralf Wildenhues. + 2008-11-12 Ralf Wildenhues Wrap keywords in `testsuite --list' output. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 92c224a17..4081604f8 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -12313,10 +12313,15 @@ implementation-specific actions. This macro is deprecated, since @defmac AS_INIT @asindex{INIT} +@evindex LC_ALL +@evindex SHELL Initialize the M4sh environment. This macro calls @code{m4_init}, then outputs the @code{#! /bin/sh} line, a notice about where the output was generated from, and code to sanitize the environment for the rest of the -script. Finally, it changes the current diversion to @code{BODY}. +script. Among other initializations, this sets @env{SHELL} to the shell +chosen to run the script (@pxref{CONFIG_SHELL}), and @env{LC_ALL} to +ensure the C locale. Finally, it changes the current diversion to +@code{BODY}. @end defmac @defmac AS_INIT_GENERATED (@var{file}, @ovar{comment}) @@ -19404,6 +19409,7 @@ for an example). @file{config.status} checks several optional environment variables that can alter its behavior: +@anchor{CONFIG_SHELL} @defvar CONFIG_SHELL @evindex CONFIG_SHELL The shell with which to run @command{configure} for the @option{--recheck} diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 15377cbea..1e9056a3c 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -417,7 +417,7 @@ cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= -AC_SUBST([SHELL], [${CONFIG_SHELL-/bin/sh}])dnl +AC_SUBST([SHELL])dnl AC_SUBST([PATH_SEPARATOR])dnl # Identity of this package. diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index e0b7c55b8..2790d8a2c 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -271,10 +271,9 @@ Then install a modern shell, or manually run the script under such a shell if you do have one.], [$[]0: ], [], [62])") fi AS_EXIT(1)])]) -else - SHELL=$CONFIG_SHELL - export SHELL fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL _m4_popdef([AS_EXIT])])# _AS_DETECT_BETTER_SHELL diff --git a/tests/m4sh.at b/tests/m4sh.at index 55363d8a8..214b5559f 100644 --- a/tests/m4sh.at +++ b/tests/m4sh.at @@ -1138,3 +1138,38 @@ cleanup 1 ]]) AT_CLEANUP + + +## ------------------- ## +## AS_INIT_GENERATED. ## +## ------------------- ## + +AT_SETUP([AS@&t@_INIT_GENERATED]) + +AT_DATA_M4SH([script.as], [[dnl +m4_define([AS_MESSAGE_FD], [1]) +AS_INIT +AS_INIT_GENERATED([child], [echo hello from child]) +cat >>child <<\EOF +AS_ECHO(["SHELL=$SHELL"]) +EOF +echo hello from parent +AS_ECHO(["SHELL=$SHELL"]) +]]) + +AT_CHECK_M4SH +AT_CHECK([./script], [0], [stdout]) +AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore]) +sed s/parent/child/ expout +AT_CHECK([./child], [0], [expout]) +SHELL=/bogus +export SHELL +cp stdout expout +mv child child.bak +AT_CHECK([./script], [0], [expout]) +AT_CHECK([cmp child child.bak]) +AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore]) +sed s/parent/child/ expout +AT_CHECK([./child], [0], [expout]) + +AT_CLEANUP