Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Zsh 3.1.6 - ${~foo} expansion bug



The following script:

#!/bin/zsh
foo=*
echo
for bar in ${~foo}; do
    echo Looping: $bar;
done

works as expected, that is, the wildcard is evaluated in line 4:

nostromo:/tmp/foodir % ls
file1  file2  file3  zshbug*
nostromo:/tmp/foodir % ./zshbug 

Looping: file1
Looping: file2
Looping: file3
Looping: zshbug

However, when I remove that redundant-looking 'echo' command...

#!/bin/zsh
foo=*
#echo
for bar in ${~foo}; do
    echo Looping: $bar;
done

...the printout changes to this:

nostromo:/tmp/foodir % ./zshbug 
Looping: file1 file2 file3 zshbug

...and even stranger, when I additionally change the command 
'echo Looping: $bar;' to 'echo Looping: /usr/$bar;' I get:

Looping: /usr/X11R6 /usr/bin /usr/dict /usr/doc /usr/games
/usr/i486-linuxlibc1 /usr/include /usr/info /usr/lib /usr/local /usr/man
/usr/sbin /usr/share /usr/src

Again, putting that redundant echo before the for loop makes the script
behave in the proper way. 

These results were obtained with zsh 3.1.6 from the Debian Potato
distribution. When run under zsh 3.0.5-15 from RedHat 6.1 the scripts
produce the expected results (the ones obtained with the redundant echo
command before the loop). It seems that zsh 3.1.6 evaluates wildcards a
bit late in some situations.

---------------------------------------------------------------------
--- If tar, vodka and sauna don't help, then the condition is mortal.  
--- +358503312601 - http://www.hut.fi/~jplauril/




Messages sorted by: Reverse Date, Date, Thread, Author