The IFS is involved in the parsing of the command line (word splitting) and in variable assignment during the read built-in execution.
But there is a side effect, which I have only discovered recently, by accident. If you assign positional parameters with set:
$ set a 'b c' d 'e f'
than using the * parameter we can get at the values individually or as one word. To illustrate, try the following:
$ echo $* "$*"
a b c d e f a b c d e f
However, if you 'nullify' the IFS variable:
$ IFS=""
then the behaviour of the shell when referencing the * parameter changes:
$ echo $* "$*"
a b c d e f ab cde f
This only works with the * parameter (not with @) and only if IFS had a null value (if you inset IFS altogether, then the shell will use a space to separate positional parameters.
Finally, I've checked this behaviour in ksh and bash - same (and documented in manual pages, at least in bash).
Twitter Updates
G-AVLN in front of her home
Mostly Unix and Linux topics. But flying might get a mention too.
Subscribe to:
Post Comments (Atom)
Blog Archive
- October (1)
- June (1)
- April (2)
- February (3)
- June (1)
- March (1)
- August (3)
- July (2)
- June (1)
- March (1)
- June (3)
- May (1)
- April (5)
- February (1)
- January (5)
- October (1)
- September (3)
- July (4)
- June (5)
- April (3)
- March (1)
- February (3)
- January (3)
- October (7)
- August (2)
- July (3)
- May (1)
- November (4)
- October (1)
- September (1)
- August (2)
- July (2)
- June (3)
- May (3)
- April (2)
- March (2)
- February (3)
- January (1)
- December (2)
- November (1)
- October (6)
- September (6)
- August (1)
- July (2)
- June (8)
- May (3)
- April (4)
- March (3)
No comments:
Post a Comment