如果我将命令替换的输出分配给局部变量,如何获取命令的退出状态?
这是 ZSH 5.8 的行为:
false; echo $? # output is 1 as expected
foo=$(false); echo $? # output is 1 as expected
local foo=$(false); echo $? # output is 0
如果我将命令替换的输出分配给局部变量,如何获取命令的退出状态?
这是 ZSH 5.8 的行为:
false; echo $? # output is 1 as expected
foo=$(false); echo $? # output is 1 as expected
local foo=$(false); echo $? # output is 0