In my Korn shell days I could do the following:
#!/bin/ksh
(
echo a=1
echo b=2
) |
while read line
do
name=${line%%=*}
val=${line#*=}
eval "$name=$val"
eval "echo $name=\$$name"
done
echo a=$a
echo b=$b
Output:
a=1
b=2
a=1
b=2
Meaning that the while loop runs in the foreground shell.
But when you run that in bash, you get:
a=1
b=2
a=
b=
Meaning that it runs in a sub-shell.
I know of other mechanisms to get what I want for this specific usage, however, is there a way to make bash run it in the foreground like ksh?