bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'For' loops with empty 'in' expansions no longer work.


From: Paul Jarc
Subject: Re: 'For' loops with empty 'in' expansions no longer work.
Date: Fri, 19 Apr 2002 21:45:55 -0400
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i686-pc-linux-gnu)

address@hidden wrote:
>       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.

No, it doesn't.

> Repeat-By:
>
>       for i in ; do echo foo; done

This *is* an error, but it's different code.  A variable with an empty
value is different from no variable at all.  I assume you have
something like this in a Makefile:
        for i in $(var); do
          use $$i
        done
You can make it work like this:
        var="$(var)"
        for i in $$var; do
          use $$i
        done


paul



reply via email to

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