Go to the first, previous, next, last section, table of contents.
Some shell variables should not be used, since they can 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 (see section Limitations of Shell Builtins) and a fallback value is needed. We list these values below.
CDPATH
cd
is verbose, so idioms such as
`abs=`cd $rel && pwd`' break because abs
receives the path
twice.
Setting CDPATH
to the empty value is not enough for most shells.
A simple colon is enough except for zsh
, which prefers a leading
dot:
zsh-3.1.6 % mkdir foo && (CDPATH=: cd foo) /tmp/foo zsh-3.1.6 % (CDPATH=:. cd foo) /tmp/foo zsh-3.1.6 % (CDPATH=.: cd foo) zsh-3.1.6 %(of course we could just
unset
CDPATH
, since it also
behaves properly if set to the empty string).
Life wouldn't be so much fun if @command{bash} and @command{zsh} had the
same behavior:
bash-2.02 % (CDPATH=:. cd foo) bash-2.02 % (CDPATH=.: cd foo) /tmp/fooTherefore, a portable solution to neutralize `CDPATH' is
CDPATH=${ZSH_VERSION+.}:Note that since @command{zsh} supports @command{unset}, you may unset `CDPATH' using `:' as a fallback, see section Limitations of Shell Builtins.
IFS
IFS
to backslash. Indeed,
Bourne shells use the first character (backslash) when joining the
components in `"$@"' and some shells then re-interpret (!) the
backslash escapes, so you can end up with backspace and other strange
characters.
LANG
LC_ALL
LC_TIME
LC_CTYPE
LANGUAGE
LC_COLLATE
LC_NUMERIC
LC_MESSAGES
set
! Non-C
@env{LC_CTYPE} values break the ctype check. Fixing @env{LC_COLLATE}
makes scripts more portable in some cases. For example, it causes the
regular expression `[a-z]' to match only lower-case letters on
ASCII platforms. However, `[a-z]' does not work in general
even when @env{LC_COLLATE} is fixed; for example, it does not work for
EBCDIC platforms. For maximum portability, you should use regular
expressions like `[abcdefghijklmnopqrstuvwxyz]' that list
characters explicitly instead of relying on ranges.
If one of these variables is set, you should try to unset it,
using `C' as a fall back value. see section Limitations of Shell Builtins,
builtin @command{unset}, for more details.
NULLCMD
NULLCMD
is
`:', while @command{zsh}, even in Bourne shell compatibility mode,
sets NULLCMD
to `cat'. If you forgot to set NULLCMD
,
your script might be suspended waiting for data on its standard input.
status
zsh
(at least 3.1.6),
hence read-only. Do not use it.
PATH_SEPARATOR
PATH_SEPARATOR
variable can be set to
either `:' or `;' to control the path separator @command{bash}
uses to set up certain environment variables (such as
PATH
). Since this only works inside bash, you want autoconf to
detect the regular DOS path separator `;', so it can be safely
substituted in files that may not support `;' as path separator. So
either unset this variable or set it to `;'.
RANDOM
RANDOM
, a variable that returns a different
integer when used. Most of the time, its value does not change when it
is not used, but on IRIX 6.5 the value changes all the time. This
can be observed by using @command{set}.
Go to the first, previous, next, last section, table of contents.