On Wed Feb 18 2009 16:52:34 Chris wrote:
> Wow, that hadn't occurred to me at all. Even more nakedly:
>
> bash$ IFS=,
> bash$ echo $IFS
>
> bash$ echo "$IFS"
> ,
even more interesting, I think:
bash$ IFS=b
bash$ echo aba
aba
bash$ echo "a${IFS}a"
aba
bash$ echo a${IFS}a
a a
bash$ foo=b
bash$ echo a${foo}a
a a
bash$ echo a`echo b`a
a a
bash$ echo a$(echo b)a
a a
bash$ echo $(echo aba)
a a
bash$ foo=ba
bash$ echo a${foo}
a a
The man page says simply than $IFS is used:
- for word splitting after expansion
- by the read builtin to split lines into words
indeed:
bash$ read c d
abc
bash$ echo $c
a
bash$ echo $d
c
Why does the IFS only get treated as IFS when it is produced by an expansion?
Why doesn't it do word splitting on the portions that were not expanded?
How does this work in the default case--where nothing is expanded?
Is there another variable or is white-space just a hard-coded builtin
separator?
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/