bug-bash
[Top][All Lists]
Advanced

[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: Fri, 13 Jul 2001 12:56:07 +0200

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 conformant, /usr/xpg4/bin/sh is
the really conformant versions, when conformance breaks
back-compatibility with older solaris versions):

$ /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

$ /bin/ksh -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

Without expansion:

$ /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/xpg4/bin/sh -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

$ 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]