Bash expansion question

Nicholas Leippe nick at
Wed Feb 18 17:21:47 MST 2009

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
bash$ echo "a${IFS}a"
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


bash$ read c d
bash$ echo $c
bash$ echo $d

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 

More information about the PLUG mailing list