[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
List expansion in a 'for in' control structure
From: |
Till Halbach |
Subject: |
List expansion in a 'for in' control structure |
Date: |
Fri, 29 Jul 2005 13:19:15 +0200 |
User-agent: |
Opera M2/8.02 (Linux, build 1272) |
Configuration Information:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-pc-linux-gnu'
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H -I. -I../bash
-I../bash/include -I../bash/lib -g -O2
uname output: Linux pc052 2.4.27-1-386 #1 Fri Sep 3 06:24:46 UTC 2004 i686
GNU/Linux
Machine Type: i386-pc-linux-gnu
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
The bash manual for the control structure 'for name [ in word ] ; do list
; done' says:
'The list of words following in is expanded, generating a list of
items.' However, if no files are found, it is set equal to the query
string.
Repeat-By:
Assume you have a directory with some files beginning with 'a' and none
beginning with 'z'.
for file in a*.html; do echo $file; done
abbr.html
acronym.html
address.html
a.html
applet.html
for file in z*.html; do echo $file; done
z*.html
Fix:
If no files are found, the list of words (represented by word in the
command description above) should expand to a zero-element array, but not
to the word itself.
BR,
Till
- List expansion in a 'for in' control structure,
Till Halbach <=