为什么在bash 3.2中source命令不能与进程替换一起使用? [英] Why source command doesn't work with process substitution in bash 3.2?
本文介绍了为什么在bash 3.2中source命令不能与进程替换一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下shell脚本:
I've the following shell script:
cat <(echo foo)
source <(echo bar=bar)
echo $bar
但是,它在GNU bash 3.2和4.3中的工作方式有所不同,如下所示:
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.
如果这是预期的行为,我应该使用什么其他语法代替source
来自标准输入的内容,以便在不同的bash版本之间兼容?
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?
推荐答案
查看全文