Yes, that's expected. If a command substitution undergoes word splitting, the 
output will be split on whitespace. If it doesn't (you use the "$(...)" form, 
with quotes around), the output forms a single word, which will result in 'a b 
c' as the single value of $k.

This will do what you want:

$ eval "for k in $(echo \"a b\" c); do echo \$k; done"
a b
c

First the command substitution is performed inside the double quoted string, 
resulting in

eval 'for k in "a b" c; do echo $k; done'

being executed. Running scripts with 'set -xv' is helpful in figuring out this 
sort of thing.



_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to