IFS behaviour (was: ash vs. bash)
On Fri 06 Aug 1999, Carlo Strozzi wrote:
> I truly believe that using ash as the basic bourne shell would be a step
> forward toward a more 'compliant' and certainly a faster system, another
I have a related topic. I've recently been playing around with the IFS
setting, not having used it for more than 10 years since having learnt
about it at school (I'm talking 1984 here, on a PDP-11/60 with a
whopping 128kB memory, but I digress).
IFS used to be used for _all_ argument separations; hence, this would
lead to $# being set to 3:
$ set a:b:c
To see what exactly happens:
$ echo a:b:c
a b c
It also meant that you could do mean things like
and people with less shell experience got totally confused:
$ ls -al
-: No such file or directory
l: No such file or directory
(this has useful purposes in especially shell scripts BTW).
However, I just noticed that this behaviour has changed in just about
any shell I tried, the only exception being Solaris' /bin/sh which still
does what I expect (and what is in fact documented in the various man
The current behaviour seems to be that IFS is only being used when
evaluating things the second time round; i.e.. like this:
$ set a:b:c
$ echo "$1"
$ echo $1
a b c
Can anyone shed some light on this? Is this something mandated by POSIX?
I mean, it's too much of a coincidence that ash, bash, ksh all have this
new (and for me unexpected) behaviour. It also shed new light on the
meaning of "Bourne shell compatibility"; I'll look this up in the book I
have at home written by Bourne himself...
Better, faster, | home: firstname.lastname@example.org http://www.wurtel.demon.nl/
cheaper: | debian: email@example.com isdn4linux: firstname.lastname@example.org
choose any two. | work: email@example.com Murphy Software, Enschede, NL