wrong filename returned by for in

2009-05-12 Thread Miche
Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include
-I../bash/lib   -g -O2 -Wall uname output: Linux klappi 2.6.19.1 #18
Fri Mar 23 12:15:17 CET 2007 i686 GNU/Linux Machine Type:
i486-pc-linux-gnu

Bash Version: 3.2
Patch Level: 48
Release Status: release

Description:
the for in command returns wrong filename, if more than one
spaces are in sequence. Multiple spaces are converted to one
single space.

Repeat-By:
touch file\ \ with\ more\ than\ one\ spaces\ \ \ in\ sequence
ls -1 file*
for a in file* ; do echo $a ; done




Re: wrong filename returned by for in

2009-05-12 Thread Andreas Schwab
Miche  writes:

> Repeat-By:
>   touch file\ \ with\ more\ than\ one\ spaces\ \ \ in\ sequence
>   ls -1 file*
>   for a in file* ; do echo $a ; done

Insufficient quoting.  The expansion of $a undergoes word splitting, you
have to quote it to suppress that.

for a in file* ; do echo "$a" ; done

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."