考虑:
$ read -r a <<<$(echo "foo"; exit 1)
$ echo $?
0当我真正期望得到1时,这将返回0。如何从子subshell中提取真正的退出代码?
发布于 2023-02-01 13:03:20
您需要多个步骤:
output=$(echo "foo"; exit 1)
status=$?
read -r a <<<"$output" # assuming the "real" code here is more complexhttps://unix.stackexchange.com/questions/733941
复制相似问题