From 4c22b10a383dc8efd21b748c2e4da8b15b9aa508 Mon Sep 17 00:00:00 2001 From: "Steve Lee [MSFT]" Date: Wed, 16 Aug 2017 15:04:03 -0700 Subject: [PATCH] Update powershell console exit codes to match Unix standards --- .../host/msh/ConsoleHost.cs | 13 +++++-------- test/powershell/Host/ConsoleHost.Tests.ps1 | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index c2eb41a1f8..a2bb66e1ce 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -53,10 +53,10 @@ namespace Microsoft.PowerShell { #region static methods - internal const uint ExitCodeSuccess = 0x00000000; - internal const uint ExitCodeCtrlBreak = 0xFFFE0000; - internal const uint ExitCodeInitFailure = 0xFFFF0000; - internal const uint ExitCodeBadCommandLineParameter = 0xFFFD0000; + internal const int ExitCodeSuccess = 0; + internal const int ExitCodeCtrlBreak = 128+21; // SIGBREAK + internal const int ExitCodeInitFailure = 70; // Internal Software Error + internal const int ExitCodeBadCommandLineParameter = 64; // Command Line Usage Error // NTRAID#Windows Out Of Band Releases-915506-2005/09/09 // Removed HandleUnexpectedExceptions infrastructure @@ -212,10 +212,7 @@ namespace Microsoft.PowerShell { s_theConsoleHost.ui.WriteErrorLine(ConsoleHostStrings.ConflictingServerModeParameters); } - unchecked - { - return (int)ExitCodeBadCommandLineParameter; - } + return ExitCodeBadCommandLineParameter; } // First check for and handle PowerShell running in a server mode. diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 4bb8b8b058..63b081b5f5 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -52,6 +52,7 @@ Describe "ConsoleHost unit tests" -tags "Feature" { BeforeAll { $powershell = Join-Path -Path $PsHome -ChildPath "powershell" + $ExitCodeBadCommandLineParameter = 64 function NewProcessStartInfo([string]$CommandLine, [switch]$RedirectStdIn) {