在bash中,如何将stdin和stdout文件句柄存储在变量中?

问题描述 投票:0回答:1

我有以下

bash
脚本:

STDIN='&0'
if some-condition; then
  STDIN=some-filename
fi

run-command <${STDIN}

但是

&0: No such file or directory
会出现错误。

类似地

STDOUT

我尝试过使用

eval
但也没有成功。

需要做什么才能使其发挥作用?

bash
1个回答
0
投票

run-command $(eval "<${STDIN}")
有效。

© www.soinside.com 2019 - 2024. All rights reserved.