Разница между $? и $ LastExitCode в PowerShell
В 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, но $? = False в PowerShell. Перенаправление stderr в stdout дает NativeCommandError.