Re: IFS behaviour (was: ash vs. bash)
On Fri 06 Aug 1999, Stephen Zander wrote:
> >>>>> "Paul" == Paul Slootman <firstname.lastname@example.org> 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: email@example.com http://www.wurtel.demon.nl/
debian: firstname.lastname@example.org isdn4linux: email@example.com
work: firstname.lastname@example.org Murphy Software, Enschede, NL