Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 06 Mar 2000 00:59:39 -0800
From:      Doug Barton <Doug@gorean.org>
To:        Sheldon Hearn <sheldonh@uunet.co.za>
Cc:        Max Khon <fjoe@iclub.nsu.ru>, hackers@FreeBSD.ORG
Subject:   Re: empty lists in for
Message-ID:  <38C3737B.63ACC551@gorean.org>
References:  <33397.952332067@axl.ops.uunet.co.za>

next in thread | previous in thread | raw e-mail | index | archive | help
Sheldon Hearn wrote:
> 
> On Sat, 04 Mar 2000 15:36:43 +0200, Sheldon Hearn wrote:
> 
> > I seem to remember POSIX being ambiguous on this one, but my books
> > are at the office.  If you haven't gotten a more conclusive answer by
> > Monday, mail me and I'll look it up.
> 
> I was wrong about POSIX being ambiguous in this regard; it's SUSV2 which
> is ambiguous.  From POSIX.2 3.9.4.2:
> 
>         First, the list of words following _in_ shall be expanded to
>         generate a list of items.  Then, the variable <name> shall be
>         set to each item, in turn, and the <compound-list> executed each
>         time.  If no items result from the expansion, the
>         <compound-list> shall not be executed. [...]
> 
>         Exit Status:  The exit status of a _for_ command shall be the
>         exit status of the last command that executes.  If there are no
>         items, the exit status shall be zero.
> 
> > Neither bash nor ksh claim to be particularly POSIX compliant.  our
> > /bin/sh does.
> 
> This is the part of my original post that Doug barton objected to.
> Perhaps bash has POSIX compliance as one of its goals, which invalidates
> my original statement.  On this score, however, both bash and ksh are
> not compliant.

	I think that Martin's post contained the informative bit:

I just checked POSIX 1003.2.

for name [ in word ] 
do
        compound-list
done

the "in word" is optional. Therefore:

for name in ; do echo $name; done

is an error, whereas

for name ; do echo $name; done

is not, and Bash does not report it as so, in or out of POSIX mode.
Also, your snippet clearly expects that there will be a word after "in."
It could easily be argued from that context that the presence of "in"
without a "word" to go with it is an error, even without the bit from
Martin's post. 

	All that said, if the ports make system depends on the current
behavior, it has to be fixed before we can contemplate any changes. 

Doug
-- 
"Welcome to the desert of the real." 

    - Laurence Fishburne as Morpheus, "The Matrix"


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38C3737B.63ACC551>