]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* acgeneral.m4 (AC_SHELL_UNSET, AC_SHELL_UNSETENV): New macro.
authorAkim Demaille <akim@epita.fr>
Fri, 19 May 2000 11:54:04 +0000 (11:54 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 19 May 2000 11:54:04 +0000 (11:54 +0000)
(_AC_INIT_PREPARE_ENVIRONMENT): Use AC_SHELL_UNSETENV.
Set CDPATH.  Fixes Autoconf/96.

* doc/autoconf.texi (Special Shell Variables): New node.
Document `status', `CDPATH', `LANG', `LC_ALL', `LC_MESSAGES' and
`LC_CTYPE'.

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

index ff54358d29261f594da41708d03e5654873dcbf0..541a4d6c5888dfc02594dbf68d7c494ee430945d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-05-19  Akim Demaille  <akim@epita.fr>
+
+       * acgeneral.m4 (AC_SHELL_UNSET, AC_SHELL_UNSETENV): New macro.
+       (_AC_INIT_PREPARE_ENVIRONMENT): Use AC_SHELL_UNSETENV.
+       Set CDPATH.  Fixes Autoconf/96.
+
+       * doc/autoconf.texi (Special Shell Variables): New node.
+       Document `status', `CDPATH', `LANG', `LC_ALL', `LC_MESSAGES' and
+       `LC_CTYPE'.
+
 2000-05-12  Akim Demaille  <akim@epita.fr>
 
        * acgeneral.m4 (sinclude): Define, some packages (binutils) need
index b8efdd38a14ee8bfb9ad9bb4db65d513c49e5434..b37d9a30a8efb0c5450876b2f554a2b8f85d939c 100644 (file)
@@ -473,6 +473,22 @@ $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],
+[$ac_unset $1 || test ${$1+set} != set || $1=$2 && export $1])
+
+
 ## --------------------------------------------------- ##
 ## Common m4/sh handling of variables (indirections).  ##
 ## --------------------------------------------------- ##
@@ -1436,29 +1452,33 @@ fi])dnl
 ])# _AC_INIT_VERSION
 
 
-
 # _AC_INIT_PREPARE_ENVIRONMENT
 # ----------------------------
 # Tune the envvar we depend upon: IFS, NLS.
-# FIXME: CDPATH.
 define([_AC_INIT_PREPARE_ENVIRONMENT],
-[# NLS nuisances.
-# Only set these to C if already set.  These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
+[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])
 
 # IFS
 # We need space, tab and new line, in precisely that order.
 ac_nl='
 '
-IFS="  $ac_nl"dnl
+IFS="  $ac_nl"
+
+# CDPATH.
+AC_SHELL_UNSETENV([CDPATH], [:])
 ])
 
+
 # _AC_INIT_PREPARE
 # ----------------
 # Called by AC_INIT to build the preamble of the `configure' scripts.
index d82ab093ad4840a71955372f3b13a2abe427782f..1e0c667b175bc8746b1dea38f949624b09a77cda 100644 (file)
@@ -252,6 +252,7 @@ Checking Run Time Behavior
 
 Portable Shell Programming
 
+* Special Shell Variables::
 * Testing Values and Files::    Checking strings and files
 * Shell Substitutions::         Test and assign
 * Limitations of Usual Tools::  Portable use of portable tools
@@ -4515,13 +4516,77 @@ well; for example, don't rely on @code{ln} having a @samp{-f} option or
 @code{cat} having any options.
 
 @menu
+* Special Shell Variables::     Variables you should not change
 * Testing Values and Files::    Checking strings and files
 * Shell Substitutions::         Test and assign
 * Limitations of Usual Tools::  Portable use of portable tools
 * Exiting from Shell Scripts::  How to exit from an autoconf shell script
 @end menu
 
-@node Testing Values and Files, Shell Substitutions, Portable Shell, Portable Shell
+@node Special Shell Variables, Testing Values and Files, Portable Shell, 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.
+
+@c Alphabetical order, case insensitive, `A' before `a'.
+@table @code
+@item CDPATH
+@evindex CDPATH
+Because when this variable is set @code{cd} is verbose, idioms such as
+@samp{abs=`cd $rel && pwd`} break, since @code{abs} receives twice the
+path.
+
+@c FIXME: Which shells?  How do they behave?
+Setting @code{CDPATH} to the empty value is not enough for most shells.
+A simple colon is enough but for @code{zsh}, which prefers a leading dot:
+
+@example
+~ % mkdir foo && CDPATH=: cd foo
+~/foo
+~ % CDPATH=:. cd foo
+~/foo
+~ % CDPATH=.: cd foo
+~ %
+@end example
+
+@noindent
+(of course we could just @code{unset} @code{CDPATH}, it also behaves
+properly if set to the empty string).
+
+Therefore a portable solution to neutralize @samp{CDPATH} is
+@samp{CDPATH=$@{ZSH_VERSION+.@}:}.
+
+@item LANG
+@itemx LC_ALL
+@itemx LC_MESSAGES
+@itemx LC_CTYPE
+@evindex LANG
+@evindex LC_ALL
+@evindex LC_MESSAGES
+@evindex LC_CTYPE
+
+These must not be set unconditionally because not all systems understand
+e.g. @strong{LANG=C} (notably SCO).  Fixing @code{LC_MESSAGES} prevents
+Solaris @command{sh} from translating var values in @code{set}!  Non-C
+@code{LC_CTYPE} values break the ctype check.  Therefore, run:
+
+@example
+test "$@{LANG+set@}" = set && LANG=C && export LANG
+test "$@{LC_ALL+set@}" = set && LC_ALL=C && export LC_ALL
+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 status
+@evindex status
+This variable is an alias to @samp{$?} for @code{zsh} (at least 3.1.6),
+hence read-only.  Do not use it.
+@end table
+
+
+@node Testing Values and Files, Shell Substitutions, Special Shell Variables, Portable Shell
 @subsection Testing Values and Files
 
 @code{configure} scripts need to test properties of many files and
index b8efdd38a14ee8bfb9ad9bb4db65d513c49e5434..b37d9a30a8efb0c5450876b2f554a2b8f85d939c 100644 (file)
@@ -473,6 +473,22 @@ $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],
+[$ac_unset $1 || test ${$1+set} != set || $1=$2 && export $1])
+
+
 ## --------------------------------------------------- ##
 ## Common m4/sh handling of variables (indirections).  ##
 ## --------------------------------------------------- ##
@@ -1436,29 +1452,33 @@ fi])dnl
 ])# _AC_INIT_VERSION
 
 
-
 # _AC_INIT_PREPARE_ENVIRONMENT
 # ----------------------------
 # Tune the envvar we depend upon: IFS, NLS.
-# FIXME: CDPATH.
 define([_AC_INIT_PREPARE_ENVIRONMENT],
-[# NLS nuisances.
-# Only set these to C if already set.  These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
+[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])
 
 # IFS
 # We need space, tab and new line, in precisely that order.
 ac_nl='
 '
-IFS="  $ac_nl"dnl
+IFS="  $ac_nl"
+
+# CDPATH.
+AC_SHELL_UNSETENV([CDPATH], [:])
 ])
 
+
 # _AC_INIT_PREPARE
 # ----------------
 # Called by AC_INIT to build the preamble of the `configure' scripts.