]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* doc/autoconf.texi (Limitations of Builtins): Document `unset'.
authorAkim Demaille <akim@epita.fr>
Wed, 24 May 2000 13:00:34 +0000 (13:00 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 24 May 2000 13:00:34 +0000 (13:00 +0000)
(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.

ChangeLog
acgeneral.m4
aclocal.m4
configure
doc/autoconf.texi
lib/autoconf/general.m4

index 5163553f1892b1e321045050b520370b5d1a61fc..c20673f96bc3e7642a9b13a307361d356085dfad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+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*
index 1f1f8f865d7b01fb0170525b4a6fb3dea41fc93f..4095182680d2e7251fa5dc1b5f4ba9757b478a8f 100644 (file)
@@ -473,19 +473,11 @@ $debug ||
 ])# _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])
 
 
@@ -1466,19 +1458,28 @@ fi])dnl
 
 # _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.
@@ -1487,7 +1488,7 @@ ac_nl='
 IFS="  $ac_nl"
 
 # CDPATH.
-AC_SHELL_UNSETENV([CDPATH], [:])
+AC_SHELL_UNSET([CDPATH], [:])
 ])
 
 
index dddb35e0d3cf6bde437626f6d72ee6f00a6eefb2..61d205c26d7d8e60eddc73d6997912cea0817179 100644 (file)
@@ -2,3 +2,4 @@ m4_include([m4/init.m4])
 m4_include([m4/missing.m4])
 m4_include([m4/sanity.m4])
 m4_include([m4/atconfig.m4])
+m4_include([m4/m4.m4])
index 9285dd3fa3b93c492280180e816e6a1898ccf35c..1b3f9ef24061cd5a573e97d4c5bc63c3b3f5c822 100755 (executable)
--- a/configure
+++ b/configure
@@ -111,9 +111,9 @@ do
     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)
@@ -175,10 +175,10 @@ do
 
   -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)
@@ -314,9 +314,9 @@ do
     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 ;;
@@ -383,7 +383,7 @@ Try \`configure --help' for more information." >&2; exit 1; }
       *[^-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
@@ -407,6 +407,12 @@ do
   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
@@ -546,6 +552,15 @@ gives unlimited permission to copy, distribute and modify it.
 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
@@ -694,7 +709,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
 # 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
@@ -741,7 +756,7 @@ fi
     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}.
@@ -752,7 +767,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
 
 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
@@ -789,7 +804,7 @@ else
 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=
@@ -810,7 +825,7 @@ test "$program_suffix" != NONE &&
 # 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
@@ -830,11 +845,11 @@ fi
 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
@@ -856,78 +871,78 @@ cat >>confdefs.h <<EOF
 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
 
@@ -942,7 +957,7 @@ for ac_prog in gm4 gnum4 m4
 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
@@ -967,10 +982,10 @@ esac
 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
 
@@ -978,7 +993,7 @@ test -n "$M4" && break
 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
@@ -990,7 +1005,7 @@ if test x"$M4" != x; then
   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; }
@@ -1003,7 +1018,7 @@ for ac_prog in mawk gawk nawk awk
 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
@@ -1028,10 +1043,10 @@ fi
 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
 
@@ -1039,25 +1054,25 @@ test -n "$AWK" && break
 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
@@ -1083,10 +1098,10 @@ esac
 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
 
@@ -1107,7 +1122,7 @@ 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
@@ -1154,7 +1169,7 @@ fi
     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}.
index 750b62430a2c02ad7d039a8f37f64d7814f3ae2d..0321a540d6b5ef6e71c46013f896c068267ab8a1 100644 (file)
@@ -253,6 +253,7 @@ Checking Run Time Behavior
 
 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
@@ -283,7 +284,7 @@ Quoting
 * 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
 
@@ -668,7 +669,7 @@ AC_MSG_WARN([[AC_DC stinks  --Iron Maiden]])
 @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
 
@@ -4524,23 +4525,54 @@ restriction allows users to start out with a fairly small set of
 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
@@ -4577,7 +4609,9 @@ bash-2.02 % (CDPATH=.: cd foo)
 @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
@@ -4600,6 +4634,14 @@ test "$@{LC_CTYPE+set@}" = set && LC_CTYPE=C && export LC_CTYPE
 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),
@@ -4806,6 +4848,27 @@ case $ac_feature in
   *[^-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
@@ -4815,6 +4878,10 @@ The small set of tools you can expect to find on any machine can still
 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
@@ -4845,6 +4912,10 @@ honor the last pattern (eg., IRIX 6.5 and Solaris 2.5.1).  Anyway,
 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
@@ -5472,14 +5543,14 @@ macro does.  For example, @code{AC_PATH_X} has internal macros
 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
@@ -5609,7 +5680,7 @@ With this in mind, we can explore the cases where macros invoke
 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:
@@ -5737,10 +5808,10 @@ its users to leave their macro calls unquoted, which is dangerous.
 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.}
 
index 1f1f8f865d7b01fb0170525b4a6fb3dea41fc93f..4095182680d2e7251fa5dc1b5f4ba9757b478a8f 100644 (file)
@@ -473,19 +473,11 @@ $debug ||
 ])# _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])
 
 
@@ -1466,19 +1458,28 @@ fi])dnl
 
 # _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.
@@ -1487,7 +1488,7 @@ ac_nl='
 IFS="  $ac_nl"
 
 # CDPATH.
-AC_SHELL_UNSETENV([CDPATH], [:])
+AC_SHELL_UNSET([CDPATH], [:])
 ])