+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.
@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})
@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}
subdirs=
MFLAGS=
MAKEFLAGS=
-AC_SUBST([SHELL], [${CONFIG_SHELL-/bin/sh}])dnl
+AC_SUBST([SHELL])dnl
AC_SUBST([PATH_SEPARATOR])dnl
# Identity of this package.
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
]])
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