ARG_MAX
| Shells
| whatshell
| portability
| permissions
| UUOC
| ancient
| -
| ../Various
| HOME
$@"
| echo/printf
| set -e
| test
| tty defs
| tty chars
| $() vs )
| IFS
| using siginfo
| nanosleep
| line charset
| locale
This page doesn't serve any special purpose, it's just about subtle differences in IFS implementations.
2011年03月12日 (see recent changes)
A variable assignment is not subject to word splitting,
no matter what IFS is used.
endnote
However: the variables $* and $@ are special.
The actual behaviour varies among different shells.
The following results have been collected like this:
set . . ; IFS='x' var=$*; printf '%s ' "$var" var=$@; printf '%s ' "$var" var="$*"; printf '%s ' "$var" var="$@"; printf '%s\n' "$var"
Blanks are substituted with underscores to make reading easy.
The second table at the right illustrates another issue:
how is splitting with set influenced by IFS?
(commas mean separated values)
IFS [2]
unset [3]
IFS=x
IFS=
IFS='\'
$*
$@
"$*"
"$@"
$*
$@
"$*"
"$@"
$*
$@
"$*"
"$@"
$* 
$@ 
"$*"
"$@"
IFS=
.x. .x. .x. .x.
._. ._. .. ._.
.. .. .\. .\.
SEGV [4]
.x. .x. .x. .x.
.. .. .. ..
.\. .\. .\. .\.
x=:a:b:: IFS=:
set $x
IFS is ' \t\n' (space tabulator newline).
' \t\n0円'.
IFS. Modern shells allow this and the behaviour
IFS was set to the default. The column list exceptions.
SEGV occurs at least in a script expanding "$*".
Another place where Bourne and bourne-compatible shells don't
apply expansions is:
"case $variable in [...] "
The reason is probably to be syntactically robust about the content of the variable.
The traditional variants of Bourne and
Almquist shell don't apply expansions after redirection operators:
"echo text>a*"
There's a divergence with the export built-in:
VALUE='x y'; export VAR=$VALUE
This results either in
export VAR='x y' or export VAR=x y,
that is, both VAR and y are exported.
The former applies to ksh88, ksh93, bash-1/2/3/4, pdksh-5.2.14 and mksh-R28/R39.
The latter applies to the original ash, its descendants, posh-0.5.4 and POSIX.
POSIX requires this to be handled as special builtin and not assignment.
See also St駱hane Chazelas remarks about IFS handling.