Here's a simple script in bash:
foo="one two three"
for i in $foo; do
echo $i;
done
The script executes as expected:
$ ./script.ksh
one
two
three
However if I replace the loop with this:
foo="one two three"
for i in $(sed -e 's/bar/$foo/' <(echo $1));
do
echo $i
done
I execute it and this is what I get:
$ ./script.ksh bar
$foo
How can I make for expand the result of the sed command into a variable?