【发布时间】:2018-10-23 10:14:11
【问题描述】:
我无法理解这样一个事实,即在明显以 > 0 退出的命令执行上使用 Bash eval 仍然返回 0。请考虑以下示例:
> eval "$(exit 42)"
> echo $?
0
单独的命令$(exit 42) 的退出代码> 0,因此根据man 页面,eval 应该返回自己的退出状态42...
eval [arg ...]
The args are read and concatenated together into a single command. This command is
then read and executed by the shell, and its exit status is returned as the value
of eval. If there are no args, or only null arguments, eval returns 0.
我误会了什么?
【问题讨论】: