summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-01-19 06:40:44 -0800
committerJay Mundrawala <jdmundrawala@gmail.com>2015-01-19 06:40:44 -0800
commit6c724e866274a728bc66740ab352db7da7d7958f (patch)
treef795542c5f5e2bbbdc804b08b03e88ff12f9f40a
parentb9e91171f6bd4ac55d62c6b9b72838fa89a1330e (diff)
downloadchef-6c724e866274a728bc66740ab352db7da7d7958f.tar.gz
Fix up powershell script
1.) You can't set $LASTEXITCODE directly, doing so creates a local variable. I've changed it to $global:LASTEXITCODE 2.) $LASTEXITCODE can be $null. No longer using `-ne 0` to compare This should resolve Issue #2348
-rw-r--r--lib/chef/provider/powershell_script.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb
index 96955f73b6..8c79b384e9 100644
--- a/lib/chef/provider/powershell_script.rb
+++ b/lib/chef/provider/powershell_script.rb
@@ -24,8 +24,8 @@ class Chef
protected
EXIT_STATUS_EXCEPTION_HANDLER = "\ntrap [Exception] {write-error -exception ($_.Exception.Message);exit 1}".freeze
- EXIT_STATUS_NORMALIZATION_SCRIPT = "\nif ($? -ne $true) { if ( $LASTEXITCODE -ne 0) {exit $LASTEXITCODE} else { exit 1 }}".freeze
- EXIT_STATUS_RESET_SCRIPT = "\n$LASTEXITCODE=0".freeze
+ EXIT_STATUS_NORMALIZATION_SCRIPT = "\nif ($? -ne $true) { if ( $LASTEXITCODE ) {exit $LASTEXITCODE} else { exit 1 }}".freeze
+ EXIT_STATUS_RESET_SCRIPT = "\n$global:LASTEXITCODE=$null".freeze
# Process exit codes are strange with PowerShell. Unless you
# explicitly call exit in Powershell, the powershell.exe