Unterschied zwischen $? und $ LastExitCode in PowerShell
Was ist in PowerShell der Unterschied zwischen$?
und$LastExitCode
?
ich leseüber automatische Variablenund es hieß:
$? 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.
In der Definition von$?
Es erklärt nicht, was Erfolg und Misserfolg bedeuten.
Ich frage, weil ich das vermutet habe$?
ist genau dann True, wenn $ LastExitCode 0 ist, aber ich habe ein überraschendes Gegenbeispiel gefunden:$ LastExitCode = 0, aber $? = False in PowerShell. Wenn Sie stderr nach stdout umleiten, erhalten Sie NativeCommandError.