In PowerShell, qual è la differenza tra $?
e $LastExitCode
?
ho letto about automatic variables, e disse:
$? 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.
Nella definizione del $?
non spiega che cosa riesce e non riescono media.
Lo chiedo perché ho presunto che $?
è vero se e solo se $ LastExitCode è 0, ma ho trovato una sorprendente contro-esempio: $LastExitCode=0 but $?=False in PowerShell. Redirecting stderr to stdout gives NativeCommandError.
Grazie Joey. Io stesso pensavo $? significava codice di uscita diverso da zero, ma ho appena trovato un controesempio sorprendente. Vedi http://stackoverflow.com/questions/10666101/powershell-lastexitcode-0-but-false-redirecting-stderr-to-stdout-gives-nat –
Questo è interessante. Credo che questo sia un bug (perché si comporta in modo incoerente tra diversi host PowerShell). – Joey
E diversi cmdlet: @iex abcde @ per esempio non restituisce né $? = False o $ LastExitCode> 0 – majkinetor