[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
'For' loops with empty 'in' expansions no longer work.
From: |
malcolm |
Subject: |
'For' loops with empty 'in' expansions no longer work. |
Date: |
Sat, 20 Apr 2002 11:36:56 +1000 |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DSHELL -DHAVE_CONFIG_H -D_GNU_SOURCE
-D_FILE_OFFSET_BITS=64 -I. -I. -I./include -I./lib -I/usr/include -O2
-march=i386 -mcpu=i686
uname output: Linux ws14.commsecure.com.au 2.4.18 #1 Sat Apr 6 15:41:47 EST
2002 i686 unknown
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
- 'For' loops with empty 'in' expansions no longer work.,
malcolm <=