पावरशेल में $ LastExitCode, $?
और $LastExitCode
के बीच क्या अंतर है?
मैं about automatic variables पढ़ा है, और यह कहा:
$? 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 but $?=False in PowerShell. Redirecting stderr to stdout gives NativeCommandError।
धन्यवाद जॉय। मैंने खुद को $ सोचा? मतलब गैर शून्य निकास कोड, लेकिन मुझे अभी एक आश्चर्यजनक counterexample मिला है। Http://stackoverflow.com/questions/10666101/powershell-lastexitcode-0-but-false-redirecting-stderr-to-stdout-gives-nat –
यह एक दिलचस्प है। मैं यह एक बग होने पर विश्वास करता हूं (क्योंकि यह विभिन्न पावरशेल मेजबानों के बीच असंगत रूप से व्यवहार करता है)। – Joey
और विभिन्न cmdlets: उदाहरण के लिए @iex abcde @ न तो $? = झूठी या $ LastExitCode> 0 – majkinetor