在PowerShell中,$?和之间有什么区别$LastExitCode?
我读到了自动变量,它说:
$? Contains the execution status of the last operation. It contains TRUE if the last operation succeeded and FALSE if it failed.
$LastExitCode Contains the exit code of the last Windows-based program that was run.
在$?它的定义中并没有解释成功和失败意味着什么.
我问,因为$?当且仅当$ LastExitCode为0时,我才认为这是真的,但我发现了一个令人惊讶的反例:$ LastExitCode = 0但是PowerShell中的$?= False.将stderr重定向到stdout会产生NativeCommandError.