[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 'For' loops with empty 'in' expansions no longer work.
From: |
Chet Ramey |
Subject: |
Re: 'For' loops with empty 'in' expansions no longer work. |
Date: |
Mon, 22 Apr 2002 10:05:52 -0400 |
> Machine Type: i386-redhat-linux-gnu
>
> Bash Version: 2.05
> Patch Level: 8
> Release Status: release
>
> Description:
> In bash2 versions up to 2.04, a loop of the form
>
> for i in $WORDS
> do
> <stuff>
> done
>
> would not execute the loop body if $WORDS expanded to nothing.
> In version 2.05, this situation generates a syntax error.
>
> The bash documentation (info page) indicates that the 2.04
> behaviour is correct and the most recent change is incorrect.
>
> The previous behaviour was certainly more useful, since the loop
> body could be executed only if there were arguments to work with
> (e.g. in the case where <stuff> is "gcc $i" -- this clearly
> makes no sense if $i is empty).
>
> Repeat-By:
>
> for i in ; do echo foo; done
This is not at all the same thing as your example above, and should be a
syntax error according to the (now old) POSIX.2 grammar.
POSIX.2 changed the grammar, and bash-2.05a no longer requires a list of
words after the `in'.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)
Chet Ramey, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/