In <[EMAIL PROTECTED]>, John Polstra wrote: 
> In article <[EMAIL PROTECTED]>,
> Doug Barton  <[EMAIL PROTECTED]> wrote:
> > 
> >     Given that Bash in both standard and POSIX mode complains about 'for i
> > in ; do echo $i; done', I would say that it's not POSIX compatible. What
> > could/does depend on this behavior "working?"
> 
> It works for the realistic cases that might actually be useful.  E.g.,:
> 
>     x=
>     for i in $x; do
>       echo $i
>     done
> 
> works fine.  I don't think it matters very much that the pathological
> case "for i in ; ..." doesn't work.

I just checked POSIX 1003.2.

for name [ in word ] 
do
        compound-list
done

"First, the list of words following 'in' shall be expanded to generate
a list of items." [...] "If no items result from the expansion, the
compound-list shall not be executed."

<nothing> is not a word at all, so it can't be expanded, so I think
bash is corrent to complain about a syntax error.

It is clear, though, that your (John) example "variable expansion to
nothing" is not an error and both shells do it right.

To the original poster, it would have been useful to submit this as a
bug report or at least choose a subject line that indicates that
you're talking about the shell. I recognized the thread only when my
name was written and missed the beginning.

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <[EMAIL PROTECTED]> http://www.cons.org/cracauer/
BSD User Group Hamburg, Germany     http://www.bsdhh.org/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to