(Special Shell Variables): Adjust.
(Shellology): New section. Introduce bash and zsh.
(Special Shell Variables): Some data on NULLCMD.
(Quotation Thumb Rule): Rename as
(Quotation Rule of Thumb): this.
* acgeneral.m4 (AC_SHELL_UNSET): Remove.
(AC_SHELL_UNSETENV): Rename as...
(AC_SHELL_UNSET): this.
(_AC_INIT_PREPARE_ENVIRONMENT): Prepare bash and zsh.
Adjust to AC_SHELL_UNSET.
+2000-05-24 Akim Demaille <akim@epita.fr>
+
+ * doc/autoconf.texi (Limitations of Builtins): Document `unset'.
+ (Special Shell Variables): Adjust.
+ (Shellology): New section. Introduce bash and zsh.
+ (Special Shell Variables): Some data on NULLCMD.
+ (Quotation Thumb Rule): Rename as
+ (Quotation Rule of Thumb): this.
+ * acgeneral.m4 (AC_SHELL_UNSET): Remove.
+ (AC_SHELL_UNSETENV): Rename as...
+ (AC_SHELL_UNSET): this.
+ (_AC_INIT_PREPARE_ENVIRONMENT): Prepare bash and zsh.
+ Adjust to AC_SHELL_UNSET.
+
2000-05-24 Akim Demaille <akim@epita.fr>
The options --build etc. used to set `$build'. *If*
])# _AC_SHELL_TMPDIR
-# AC_SHELL_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
-# --------------------------------------------------------
-# Try to unset the env VAR, otherwise set it to
-# VALUE-IF-UNSET-NOT-SUPPORTED. `ac_unset' must have been computed.
-define([AC_SHELL_UNSET],
-[$ac_unset $1 || test "${$1+set}" != set || $1=$2])
-
-
# AC_SHELL_UNSETENV(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
-# --------------------------------------------------------
+# -----------------------------------------------------------
# Try to unset the env VAR, otherwise set it to
# VALUE-IF-UNSET-NOT-SUPPORTED. `ac_unset' must have been computed.
-define([AC_SHELL_UNSETENV],
+define([AC_SHELL_UNSET],
[$ac_unset $1 || test "${$1+set}" != set || $1=$2 && export $1])
# _AC_INIT_PREPARE_ENVIRONMENT
# ----------------------------
-# Tune the envvar we depend upon: IFS, NLS.
+# Tune the behavior of the shell.
define([_AC_INIT_PREPARE_ENVIRONMENT],
-[if (unset FOO) >/dev/null 2>&1; then
+[# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+
+# Support unset when possible.
+if (unset FOO) >/dev/null 2>&1; then
ac_unset=unset
else
ac_unset=false
fi
# NLS nuisances.
-AC_SHELL_UNSETENV([LANG], [C])
-AC_SHELL_UNSETENV([LC_ALL], [C])
-AC_SHELL_UNSETENV([LC_CTYPE], [C])
-AC_SHELL_UNSETENV([LC_MESSAGES], [C])
+AC_SHELL_UNSET([LANG], [C])
+AC_SHELL_UNSET([LC_ALL], [C])
+AC_SHELL_UNSET([LC_CTYPE], [C])
+AC_SHELL_UNSET([LC_MESSAGES], [C])
# IFS
# We need space, tab and new line, in precisely that order.
IFS=" $ac_nl"
# CDPATH.
-AC_SHELL_UNSETENV([CDPATH], [:])
+AC_SHELL_UNSET([CDPATH], [:])
])
m4_include([m4/missing.m4])
m4_include([m4/sanity.m4])
m4_include([m4/atconfig.m4])
+m4_include([m4/m4.m4])
bindir=$ac_optarg ;;
-build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
+ ac_prev=build_alias ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build=$ac_optarg ;;
+ build_alias=$ac_optarg ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
-host | --host | --hos | --ho)
cross_compiling=yes
- ac_prev=host ;;
+ ac_prev=host_alias ;;
-host=* | --host=* | --hos=* | --ho=*)
cross_compiling=yes
- host=$ac_optarg ;;
+ host_alias=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
sysconfdir=$ac_optarg ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
+ ac_prev=target_alias ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target=$ac_optarg ;;
+ target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
*[^-a-zA-Z0-9.]*) echo "configure: WARNING: invalid host type: $ac_option" >&2;;
esac
echo "configure: WARNING: you should use --build, --host, --target" >&2
- : ${build=$ac_option} ${host=$ac_option} ${target=$ac_option}
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
;;
esac
esac
done
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
EOF
exit 0
fi
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+
+# Support unset when possible.
if (unset FOO) >/dev/null 2>&1; then
ac_unset=unset
else
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
-echo "configure:610: checking for a BSD compatible install" >&5
+echo "configure:623: checking for a BSD compatible install" >&5
echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
if test -z "$INSTALL"; then
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_install_sh
fi
fi
-echo "configure:656: result: $INSTALL" >&5
+echo "configure:669: result: $INSTALL" >&5
echo "${ECHO_T}$INSTALL" >&6
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-echo "configure:663: checking whether build environment is sane" >&5
+echo "configure:676: checking whether build environment is sane" >&5
echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6
# Just in case
sleep 1
Check your system clock" >&2; exit 1; }
fi
rm -f conftest*
-echo "configure:698: result: yes" >&5
+echo "configure:711: result: yes" >&5
echo "${ECHO_T}yes" >&6
if test "$program_transform_name" = s,x,x,; then
program_transform_name=
# sed with no file args requires a program.
test -z "$program_transform_name" && program_transform_name="s,x,x,"
-echo "configure:717: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:730: checking whether ${MAKE-make} sets \${MAKE}" >&5
echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
rm -f conftestmake
fi
if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
- echo "configure:737: result: yes" >&5
+ echo "configure:750: result: yes" >&5
echo "${ECHO_T}yes" >&6
SET_MAKE=
else
- echo "configure:741: result: no" >&5
+ echo "configure:754: result: no" >&5
echo "${ECHO_T}no" >&6
SET_MAKE="MAKE=${MAKE-make}"
fi
EOF
missing_dir=`cd $ac_aux_dir && pwd`
-echo "configure:757: checking for working aclocal" >&5
+echo "configure:770: checking for working aclocal" >&5
echo $ECHO_N "checking for working aclocal... $ECHO_C" >&6
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if (aclocal --version) < /dev/null > /dev/null 2>&1; then
ACLOCAL=aclocal
- echo "configure:764: result: found" >&5
+ echo "configure:777: result: found" >&5
echo "${ECHO_T}found" >&6
else
ACLOCAL="$missing_dir/missing aclocal"
- echo "configure:768: result: missing" >&5
+ echo "configure:781: result: missing" >&5
echo "${ECHO_T}missing" >&6
fi
-echo "configure:771: checking for working autoconf" >&5
+echo "configure:784: checking for working autoconf" >&5
echo $ECHO_N "checking for working autoconf... $ECHO_C" >&6
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if (autoconf --version) < /dev/null > /dev/null 2>&1; then
AUTOCONF=autoconf
- echo "configure:778: result: found" >&5
+ echo "configure:791: result: found" >&5
echo "${ECHO_T}found" >&6
else
AUTOCONF="$missing_dir/missing autoconf"
- echo "configure:782: result: missing" >&5
+ echo "configure:795: result: missing" >&5
echo "${ECHO_T}missing" >&6
fi
-echo "configure:785: checking for working automake" >&5
+echo "configure:798: checking for working automake" >&5
echo $ECHO_N "checking for working automake... $ECHO_C" >&6
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if (automake --version) < /dev/null > /dev/null 2>&1; then
AUTOMAKE=automake
- echo "configure:792: result: found" >&5
+ echo "configure:805: result: found" >&5
echo "${ECHO_T}found" >&6
else
AUTOMAKE="$missing_dir/missing automake"
- echo "configure:796: result: missing" >&5
+ echo "configure:809: result: missing" >&5
echo "${ECHO_T}missing" >&6
fi
-echo "configure:799: checking for working autoheader" >&5
+echo "configure:812: checking for working autoheader" >&5
echo $ECHO_N "checking for working autoheader... $ECHO_C" >&6
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if (autoheader --version) < /dev/null > /dev/null 2>&1; then
AUTOHEADER=autoheader
- echo "configure:806: result: found" >&5
+ echo "configure:819: result: found" >&5
echo "${ECHO_T}found" >&6
else
AUTOHEADER="$missing_dir/missing autoheader"
- echo "configure:810: result: missing" >&5
+ echo "configure:823: result: missing" >&5
echo "${ECHO_T}missing" >&6
fi
-echo "configure:813: checking for working makeinfo" >&5
+echo "configure:826: checking for working makeinfo" >&5
echo $ECHO_N "checking for working makeinfo... $ECHO_C" >&6
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if (makeinfo --version) < /dev/null > /dev/null 2>&1; then
MAKEINFO=makeinfo
- echo "configure:820: result: found" >&5
+ echo "configure:833: result: found" >&5
echo "${ECHO_T}found" >&6
else
MAKEINFO="$missing_dir/missing makeinfo"
- echo "configure:824: result: missing" >&5
+ echo "configure:837: result: missing" >&5
echo "${ECHO_T}missing" >&6
fi
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
-echo "configure:837: checking for $ac_word" >&5
+echo "configure:850: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_M4+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
M4=$ac_cv_path_M4
if test -n "$M4"; then
- echo "configure:862: result: $M4" >&5
+ echo "configure:875: result: $M4" >&5
echo "${ECHO_T}$M4" >&6
else
- echo "configure:865: result: no" >&5
+ echo "configure:878: result: no" >&5
echo "${ECHO_T}no" >&6
fi
done
test -n "$M4" || M4="m4"
-echo "configure:871: checking whether m4 supports frozen files" >&5
+echo "configure:884: checking whether m4 supports frozen files" >&5
echo $ECHO_N "checking whether m4 supports frozen files... $ECHO_C" >&6
if test "${ac_cv_prog_gnu_m4+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
esac
fi
fi
-echo "configure:883: result: $ac_cv_prog_gnu_m4" >&5
+echo "configure:896: result: $ac_cv_prog_gnu_m4" >&5
echo "${ECHO_T}$ac_cv_prog_gnu_m4" >&6
if test x"$ac_cv_prog_gnu_m4" != xyes; then
{ echo "configure: error: GNU m4 1.4 is required" >&2; exit 1; }
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
-echo "configure:895: checking for $ac_word" >&5
+echo "configure:908: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_AWK+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
AWK=$ac_cv_prog_AWK
if test -n "$AWK"; then
- echo "configure:920: result: $AWK" >&5
+ echo "configure:933: result: $AWK" >&5
echo "${ECHO_T}$AWK" >&6
else
- echo "configure:923: result: no" >&5
+ echo "configure:936: result: no" >&5
echo "${ECHO_T}no" >&6
fi
done
# Generating man pages.
-echo "configure:929: checking for working help2man" >&5
+echo "configure:942: checking for working help2man" >&5
echo $ECHO_N "checking for working help2man... $ECHO_C" >&6
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if (help2man --version) < /dev/null > /dev/null 2>&1; then
HELP2MAN=help2man
- echo "configure:936: result: found" >&5
+ echo "configure:949: result: found" >&5
echo "${ECHO_T}found" >&6
else
HELP2MAN="\${SHELL} \${top_srcdir}/missing help2man"
- echo "configure:940: result: missing" >&5
+ echo "configure:953: result: missing" >&5
echo "${ECHO_T}missing" >&6
fi
# We use a path for perl so the #! line in autoscan will work.
# Extract the first word of "perl", so it can be a program name with args.
set dummy perl; ac_word=$2
-echo "configure:946: checking for $ac_word" >&5
+echo "configure:959: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_PERL+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
PERL=$ac_cv_path_PERL
if test -n "$PERL"; then
- echo "configure:972: result: $PERL" >&5
+ echo "configure:985: result: $PERL" >&5
echo "${ECHO_T}$PERL" >&6
else
- echo "configure:975: result: no" >&5
+ echo "configure:988: result: no" >&5
echo "${ECHO_T}no" >&6
fi
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
-echo "configure:994: checking for a BSD compatible install" >&5
+echo "configure:1007: checking for a BSD compatible install" >&5
echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
if test -z "$INSTALL"; then
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_install_sh
fi
fi
-echo "configure:1040: result: $INSTALL" >&5
+echo "configure:1053: result: $INSTALL" >&5
echo "${ECHO_T}$INSTALL" >&6
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
Portable Shell Programming
+* Shellology:: A zoology of shells
* Special Shell Variables:: Variables you should not change
* Shell Substitutions:: Test and assign
* Limitations of Builtins:: Portable use of not so portable /bin/sh
* Active Characters:: Characters that change the behavior of m4
* One Macro Call:: Quotation and one macro call
* Quotation and Nested Macros:: Macros calling macros
-* Quotation Thumb Rule:: One parenthesis, one quote
+* Quotation Rule Of Thumb:: One parenthesis, one quote
Dependencies Between Macros
@end example
You are now able to understand one of the constructs of Autoconf which
-has continuously been misunderstood... The thumb rule is that
+has continuously been misunderstood... The rule of thumb is that
@emph{whenever you expect macro expansion, expect quote expansion},
i.e., expect one level of quotes to be lost. For instance
programs and build the rest, avoiding too many interdependencies between
packages.
-Some of these external utilities have a portable subset of features, as
-well; for example, don't rely on @code{ln} having a @samp{-f} option or
-@code{cat} having any options.
+Some of these external utilities have a portable subset of features, see
+@ref{Limitations of Usual Tools}.
@menu
+* Shellology:: A zoology of shells
* Special Shell Variables:: Variables you should not change
* Shell Substitutions:: Test and assign
* Limitations of Builtins:: Portable use of not so portable /bin/sh
* Limitations of Usual Tools:: Portable use of portable tools
@end menu
-@node Special Shell Variables, Shell Substitutions, Portable Shell, Portable Shell
+@node Shellology, Special Shell Variables, Portable Shell, Portable Shell
+@subsection Shellology
+
+There are several families of shells, most prominently the Bourne
+family and the C shell family which are deeply incompatible. If you
+want to write portable shell scripts, avoid members of the C shell
+family.
+
+Below we describe some of the members of the Bourne shell family.
+
+@table @asis
+@item @command{bash}
+@cindex @command{bash}
+To detect whether you are running @command{bash}, test if
+@code{BASH_VERSION} is set. To disable its extensions and require
+@sc{posix} compatibility, run @samp{set -o posix}. @xref{Bash POSIX
+Mode,, Bash @sc{posix} Mode, bash, The GNU Bash Reference Manual}, for
+details.
+
+@item @command{zsh}
+@cindex @command{zsh}
+To detect whether you are running @command{zsh}, test if
+@code{ZSH_VERSION} is set. By default @command{zsh} is @emph{not}
+compatible with the Bourne shell: you have to run @samp{emulate sh} and
+set @code{NULLCMD} to @samp{:}. @xref{Compatibility,, Compatibility,
+zsh, The Z Shell Manual}, for details.
+@end table
+
+
+@node Special Shell Variables, Shell Substitutions, Shellology, Portable Shell
@subsection Special Shell Variables
-Some shell variables shall not be used. Since currently Autoconf does
-not use @code{unset}, there are some variables which need some specific
-values to disable the features they control.
+Some shell variables shall not be used or have a deep influence on the
+behavior of the shell. In order to recover a sane behavior from the
+shell, some variables should be unset, but @command{unset} is not
+portable (@pxref{Limitations of Builtins}) and a fall back value is
+needed. We list these values below.
@c Alphabetical order, case insensitive, `A' before `a'.
@table @code
@end example
Therefore a portable solution to neutralize @samp{CDPATH} is
-@samp{CDPATH=$@{ZSH_VERSION+.@}:}.
+@samp{CDPATH=$@{ZSH_VERSION+.@}:}. Note that since @command{zsh}
+support @command{unset}, you may unset @samp{CDPATH} using @samp{:} as a
+fall back, see @ref{Limitations of Builtins}.
@item LANG
@itemx LC_ALL
test "$@{LC_MESSAGES+set@}" = set && LC_MESSAGES=C && export LC_MESSAGES
@end example
+@item NULLCMD
+@evindex NULLCMD
+When executing the command @samp{>foo}, @command{zsh} executes
+@samp{$NULLCMD >foo}. The Bourne shell considers @code{NULLCMD} is
+@samp{:}, while @command{zsh}, even in Bourne shell compatibility mode,
+sets @code{NULLCMD} to @samp{cat}. If you forgot to set @code{NULLCMD},
+your script might be suspended waiting for data on its standard input.
+
@item status
@evindex status
This variable is an alias to @samp{$?} for @code{zsh} (at least 3.1.6),
*[^-a-zA-Z0-9_]*) @var{action};;
esac
@end example
+
+@item @command{unset}
+@cindex @command{unset}
+You cannot assume the support of @command{unset}, nevertheless, because
+it is extremely useful to disable embarrassing variables such as
+@code{CDPATH} or @code{LANG}, you can test for its existence, and use
+it @emph{provided} you give a neutralizing value when @command{unset} is
+not supported:
+
+@example
+if (unset FOO) >/dev/null 2>&1; then
+ unset=unset
+else
+ unset=false
+fi
+$unset CDPATH || CDPATH=:
+@end example
+
+@xref{Special Shell Variables}, for some neutralizing values. Also, see
+@ref{Limitations of Builtins}, documentation of @command{export}, for
+the case of environment variables.
@end table
@node Limitations of Usual Tools, , Limitations of Builtins, Portable Shell
find some limitations you should be aware of.
@table @asis
+@item @command{cat}
+@cindex @command{cat}
+Don't rely on any option.
+
@item @command{egrep}
@cindex @command{egrep}
The empty alternative is not portable, use @samp{?} instead. For
Stardent Vistra SVR4 @code{grep} lacks @samp{-e}... Instead, use
alternation and @code{egrep}.
+@item @command{ln}
+@cindex @command{ln}
+Don't rely on @code{ln} having a @samp{-f} option.
+
@item @command{sed}
@cindex @command{sed}
@code{sed} scripts should not use branch labels longer than 8 characters
The most common brokenness of existing macros is an improper quotation.
This section, which users of Autoconf can skip, but which macro writers
@emph{must} read, first justifies the quotation scheme which was chosen
-for Autoconf, and ends with the thumb rules. Understanding the former
+for Autoconf, and ends with the rule of thumb. Understanding the former
helps following the latter.
@menu
* Active Characters:: Characters that change the behavior of m4
* One Macro Call:: Quotation and one macro call
* Quotation and Nested Macros:: Macros calling macros
-* Quotation Thumb Rule:: One parenthesis, one quote
+* Quotation Rule Of Thumb:: One parenthesis, one quote
@end menu
@node Active Characters, One Macro Call, Quoting, Quoting
macros...
-@node Quotation and Nested Macros, Quotation Thumb Rule, One Macro Call, Quoting
+@node Quotation and Nested Macros, Quotation Rule Of Thumb, One Macro Call, Quoting
@subsection Quotation and Nested Macros
The examples below use the following macros:
Also, because it behaves differently from the other macro, it's an
exception, which we are avoiding in Autoconf.
-@node Quotation Thumb Rule, , Quotation and Nested Macros, Quoting
-@subsection Quotation Thumb Rule
+@node Quotation Rule Of Thumb, , Quotation and Nested Macros, Quoting
+@subsection Quotation Rule Of Thumb
-To conclude, the quotation thumb rules are:
+To conclude, the quotation rule of thumb is:
@center @emph{One pair of quotes per pair of parentheses.}
])# _AC_SHELL_TMPDIR
-# AC_SHELL_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
-# --------------------------------------------------------
-# Try to unset the env VAR, otherwise set it to
-# VALUE-IF-UNSET-NOT-SUPPORTED. `ac_unset' must have been computed.
-define([AC_SHELL_UNSET],
-[$ac_unset $1 || test "${$1+set}" != set || $1=$2])
-
-
# AC_SHELL_UNSETENV(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
-# --------------------------------------------------------
+# -----------------------------------------------------------
# Try to unset the env VAR, otherwise set it to
# VALUE-IF-UNSET-NOT-SUPPORTED. `ac_unset' must have been computed.
-define([AC_SHELL_UNSETENV],
+define([AC_SHELL_UNSET],
[$ac_unset $1 || test "${$1+set}" != set || $1=$2 && export $1])
# _AC_INIT_PREPARE_ENVIRONMENT
# ----------------------------
-# Tune the envvar we depend upon: IFS, NLS.
+# Tune the behavior of the shell.
define([_AC_INIT_PREPARE_ENVIRONMENT],
-[if (unset FOO) >/dev/null 2>&1; then
+[# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+
+# Support unset when possible.
+if (unset FOO) >/dev/null 2>&1; then
ac_unset=unset
else
ac_unset=false
fi
# NLS nuisances.
-AC_SHELL_UNSETENV([LANG], [C])
-AC_SHELL_UNSETENV([LC_ALL], [C])
-AC_SHELL_UNSETENV([LC_CTYPE], [C])
-AC_SHELL_UNSETENV([LC_MESSAGES], [C])
+AC_SHELL_UNSET([LANG], [C])
+AC_SHELL_UNSET([LC_ALL], [C])
+AC_SHELL_UNSET([LC_CTYPE], [C])
+AC_SHELL_UNSET([LC_MESSAGES], [C])
# IFS
# We need space, tab and new line, in precisely that order.
IFS=" $ac_nl"
# CDPATH.
-AC_SHELL_UNSETENV([CDPATH], [:])
+AC_SHELL_UNSET([CDPATH], [:])
])