[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unexpected IFS behaviour on 2.05 and 2.04
From: |
Lars Christensen |
Subject: |
Re: Unexpected IFS behaviour on 2.05 and 2.04 |
Date: |
Sat, 14 Jul 2001 11:53:04 +0200 (MEST) |
On Thu, 12 Jul 2001, Chet Ramey wrote:
> > Consider the following:
> >
> > bash-2.05$ A=1/2
> > bash-2.05$ IFS=/
> > bash-2.05$ for f in $A/3 ; do echo $f ; done
> > 1
> > 2 3
> > bash-2.05$
> >
> > bash-2.04$ A=1/2
> > bash-2.04$ IFS=/
> > bash-2.04$ for f in $A/3 ; do echo $f ; done
> > 1
> > 2 3
> > bash-2.04$
> >
> > Now running the same on 2.02, I see:
> >
> > bash-2.02$ A=1/2
> > bash-2.02$ IFS=/
> > bash-2.02$ for f in $A/3 ; do echo $f ; done
> > 1
> > 2
> > 3
> > bash-2.02$
>
> Bug in bash-2.02. POSIX.2 says that word splitting is performed only
> on the results of expansion. That means that the expansion of $A
> gets split, but nothing else.
On Solaris 2.8, claiming to be POSIX.2 comformant, at least with
/usr/xpg4/bin version of the program, the following happen:
$ /bin/sh -c 'a=1/2; IFS=/; for x in $a/3; do echo $x; done'
1
2
3
$ /usr/xpg4/bin/sh -c 'a=1/2; IFS=/; for x in $a/3; do echo $x; done'
1
2
3
$ /usr/dist/bin/bash -c 'a=1/2; IFS=/; for x in $a/3; do echo $x; done'
1
2 3
$ /bin/ksh -c 'a=1/2; IFS=/; for x in $a/3; do echo $x; done'
1
2
3
This is what happens without expantion:
$ /bin/sh -c 'IFS=/; for x in 1/2/3; do echo $x; done'
1
2
3
$ /usr/xpg4/bin/sh -c 'IFS=/; for x in 1/2/3; do echo $x; done'
1 2 3
$ /bin/ksh -c 'IFS=/; for x in 1/2/3; do echo $x; done'
1 2 3
$ /usr/dist/bin/bash -c 'IFS=/; for x in 1/2/3; do echo $x; done'
1 2 3
$ /usr/dist/bin/bash --version
GNU bash, version 2.05.0(1)-release (sparc-sun-solaris2.8)
Copyright 2000 Free Software Foundation, Inc.
--
Lars Christensen, larsch@cs.auc.dk