Why source command doesn't work with process substitution in bash 3.2?

I've the following shell script:

cat <(echo foo)
source <(echo bar=bar)
echo $bar

However it works differently in GNU bash 3.2 and 4.3 as shown below:

$ /bin/bash foo.sh 
foo

3.2.53(1)-release

$ /usr/local/bin/bash foo.sh 
foo
bar
4.3.33(1)-release

Why this works only on one version? Is it a bug or added feature?

It seems the process substitution works fine, however problem lay when sourcing the file.

If this is expected behaviour, what other syntax should I use instead to source something from the standard input to be compatible between different bash versions?


Solution 1:

This is a known limitation in bash 3.2. To work around it:

source /dev/stdin <<<"$(echo bar=bar)"

...or, similarly:

source /dev/stdin <<<"$(cat <(...))"