Re: IFS behaviour (was: ash vs. bash)
On Fri 06 Aug 1999, Stephen Zander wrote:
> >>>>> "Paul" == Paul Slootman <email@example.com> writes:
> Paul> The current behaviour seems to be that IFS is only being
> Paul> used when evaluating things the second time round;
> Paul> i.e.. like this:
> Paul> $ IFS=":$IFS"
> Paul> $ set a:b:c
> Paul> $ echo "$1"
> Paul> a:b:c
> Paul> $ echo $1
> Paul> a b c
> Eh? ash on my laptop gives the following
> $ IFS=":$IFS"
> $ set a:b:c
> $ echo $1
> a b c
> $ echo "$1"
Oh, bugger, cut & paste problem (I pasted the output in the wrong order).
Anyway, my point was that if ':' is contained in IFS,
should set THREE arguments, and $1 (quoted or not) should always contain
'a', $2 should be 'b', and $3 should be 'c'. That's the way the
original Bourne shell did it, and how the /bin/sh on Solaris still does
it. ksh, ash, and bash all do it differently however.
Here's the relevant quote from the ash manpage thats (in my
understanding of it) supports my argument:
White Space Splitting (Field Splitting)
After parameter expansion, command substitution, and arithmetic expansion
the shell scans the results of expansions and substitutions that did not
occur in double-quotes for field splitting and multiple fields can re
The shell treats each character of the IFS as a delimiter and use the de
limiters to split the results of parameter expansion and command substi
tution into fields.
home: firstname.lastname@example.org http://www.wurtel.demon.nl/
debian: email@example.com isdn4linux: firstname.lastname@example.org
work: email@example.com Murphy Software, Enschede, NL