Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Mar 2000 08:40:31 +0100
From:      Martin Cracauer <cracauer@cons.org>
To:        John Polstra <jdp@polstra.com>
Cc:        Doug@gorean.org, hackers@FreeBSD.ORG, fjoe@iclub.nsu.ru
Subject:   Re: empty lists in for
Message-ID:  <20000306084031.A35426@cons.org>
In-Reply-To: <200003060430.UAA85900@vashon.polstra.com>; from jdp@polstra.com on Sun, Mar 05, 2000 at 08:30:18PM -0800
References:  <Pine.BSF.4.21.0002212205230.36736-100000@iclub.nsu.ru> <57223.952177003@axl.ops.uunet.co.za> <20000305093539F.jhix@mindspring.com> <38C2B805.EA899C32@gorean.org> <200003060430.UAA85900@vashon.polstra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In <200003060430.UAA85900@vashon.polstra.com>, John Polstra wrote: 
> In article <38C2B805.EA899C32@gorean.org>,
> Doug Barton  <Doug@gorean.org> 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 <cracauer@cons.org> http://www.cons.org/cracauer/
BSD User Group Hamburg, Germany     http://www.bsdhh.org/


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?20000306084031.A35426>