diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-01-19 06:40:44 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-01-19 06:40:44 -0800 |
commit | 6c724e866274a728bc66740ab352db7da7d7958f (patch) | |
tree | f795542c5f5e2bbbdc804b08b03e88ff12f9f40a /lib/chef/provider/powershell_script.rb | |
parent | b9e91171f6bd4ac55d62c6b9b72838fa89a1330e (diff) | |
download | chef-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
Diffstat (limited to 'lib/chef/provider/powershell_script.rb')
-rw-r--r-- | lib/chef/provider/powershell_script.rb | 4 |
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 |