]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Make M4sh, not autoconf, guarantee sane $SHELL.
authorEric Blake <ebb9@byu.net>
Thu, 13 Nov 2008 03:10:09 +0000 (20:10 -0700)
committerEric Blake <ebb9@byu.net>
Thu, 13 Nov 2008 03:32:51 +0000 (20:32 -0700)
* 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 <ebb9@byu.net>
ChangeLog
doc/autoconf.texi
lib/autoconf/general.m4
lib/m4sugar/m4sh.m4
tests/m4sh.at

index 2a057487e9e80fb2b6ac6bc31eda47a109550833..634412a32c452b699b3c2576b00922be859af283 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-11-12  Eric Blake  <ebb9@byu.net>
+
+       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  <Ralf.Wildenhues@gmx.de>
 
        Wrap keywords in `testsuite --list' output.
index 92c224a178c9a25e618c23c194e96cbfbb812dd4..4081604f815034d64ec340f09c0061afd6b53850 100644 (file)
@@ -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}
index 15377cbea9dedce327dd2b24fd4f68959ce636df..1e9056a3c4eb7777adc46be5fd3b223a58c69c46 100644 (file)
@@ -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.
index e0b7c55b824b485f4bb0e0fa127498966f778b42..2790d8a2cd03e9b702458eb0c3a6e4058e76cb14 100644 (file)
@@ -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
 
 
index 55363d8a8e325ca062b01523f40c4f02c6bec9f7..214b5559fb3c2c8a5407adcf47b3c850ec8201d6 100644 (file)
@@ -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/ <stdout >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/ <stdout >expout
+AT_CHECK([./child], [0], [expout])
+
+AT_CLEANUP