[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
unset
is not portable (see section 10.8 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 bash
and zsh
had the
same behavior:
bash-2.02 % (CDPATH=:. cd foo) bash-2.02 % (CDPATH=.: cd foo) /tmp/foo |
Therefore, a portable solution to neutralize `CDPATH' is
CDPATH=${ZSH_VERSION+.}: |
Note that since zsh
supports unset
, you may unset
`CDPATH' using `:' as a fallback, see
10.8 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
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. Fixing 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 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 10.8 Limitations of Shell Builtins,
builtin unset
, for more details.
NULLCMD
zsh
executes
`$NULLCMD >foo'. The Bourne shell considers NULLCMD
is
`:', while 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 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 set
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |