Matt Zimmerman wrote: > On Wed, Sep 03, 2003 at 01:40:51PM -0700, John H. Robinson, IV wrote: > > > Matt Zimmerman wrote: > > > there:[~] /bin/bash > > > [EMAIL PROTECTED]:~$ foo="a b" > > > [EMAIL PROTECTED]:~$ for x in $foo; do echo "$x"; done > > ^^^^ > > > a > > > b > > > > $ foo="a b"; for x in "$foo"; do echo "$x" : $x; done > > a b : a b > > That misses the whole point, which was to iterate over a list of items, some > of which could contain whitespace.
i understand that. the whole point i was trying to make is that using bash and sh variables is inadequate to that task. % a=("apple tony the one and"\ \ only fred betty "wilma") % for i in $a ; do echo $i ; done apple tony the one and only fred betty wilma as i said, zsh users are excused from this excercise. for the bash purists: $ a=("one two" "a b" "i ii") $ for i in "[EMAIL PROTECTED]"; do echo "$i"; done one two a b i ii good luck setting that array from the output of find(1), though. remember, newline is a valid filename character. quick testing indicates that ``a=(*)'' works, even for files with embedded newlines. but wasn't the whole point to get away from shell expansions? in the following example, file?3 has an embedded newline, and "file 1" has an embedded space $ touch file\ 1 file2 file' > '3 $ a=(*) $ for i in "[EMAIL PROTECTED]"; do echo :"$i":; done :file 3: :file 1: :file2: -john