side effect of zsh echo?

Posted by Mirai on Stack Overflow See other posts from Stack Overflow or by Mirai
Published on 2010-06-01T23:56:07Z Indexed on 2010/06/02 0:03 UTC
Read the original article Hit count: 195

Filed under:

For some reason this script will work with all of the 'echo's at the end, but without them $wall is an empty string. This seems like really odd behaviour.

#!/bin/zsh

if [ ! -n "$1" ] ; then
    files=(~/pictures/backgrounds/*jpg)
else
    while [ $1 ] ; do
        files+=(`echo $1/*jpg`)
        shift
    done
fi
echo $files
N=${#files}
echo $N
((N=RANDOM%N))
echo $N
wall=${files[$N]}
echo $wall
cp $wall ~/wall.jpg

© Stack Overflow or respective owner

Related posts about zsh