(在 BASH 中)我希望子 shell 使用非 STDOUT 非 STDERR 文件描述符将一些数据传递回父 shell。我怎样才能做到这一点?最终,我很想将数据保存到父 shell 的某个变量中。
(
# The following two lines show the behavior of the subshell.
# We cannot change them.
echo "This should go to STDOUT"
echo "This is the data I want to pass to the parent shell" >&3
)
#...
data_from_subshell=... # Somehow assign the value of &3 of the
# subshell to this variable
编辑:子shell 运行一个写入STDOUT 和&3 的黑盒程序。