[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
null word list in for loops in bash-2.05.8 not allowed
From: |
cpg |
Subject: |
null word list in for loops in bash-2.05.8 not allowed |
Date: |
Sun, 18 Nov 2001 00:38:37 -0600 |
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 caesar 2.4.7-10smp #1 SMP Thu Sep 6 17:09:31 EDT 2001 i686
unknown
Machine Type: i386-redhat-linux-gnu
Bash Version: 2.05
Patch Level: 8
Release Status: release
Description:
it is not clear if this is a bug:
bash$ for i in ; do echo hi; done
bash: syntax error near unexpected token `;'
bash$
the manual says the following:
"If the expansion of the items following in results in an
empty list, no commands are executed, and the return status is
0."
what makes me doubt is this:
bash$ for i in $NOTHING ; do echo hi; done
bash$
with NOTHING not being defined. the problem is that a makefile
we have issues this loop:
for i in $(SOMETHING); do \
install $$i ..... ; \
done
but some times, $(SOMETHING) expands to nothing at all in the
makefile and fails the compilation process with the syntax
error mentioned above. i think what is going on is that it is
passed down on the shell in the form with nothing in between
the 'in' and the ';' and therefore we get the failure.
is there any harm to doing no iterations when nothing is suppied.
seems clean and elegant enough. is this a matter of standards, or is
it a bug?
if it is expected behavior, do you have a proposal of a clean
solution in the makefile?
this is the bash that comes in redhat 7.2, btw.
Repeat-By:
for i in ; do echo hi; done
Fix:
- null word list in for loops in bash-2.05.8 not allowed,
cpg <=