From 6c724e866274a728bc66740ab352db7da7d7958f Mon Sep 17 00:00:00 2001 From: Jay Mundrawala Date: Mon, 19 Jan 2015 06:40:44 -0800 Subject: 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 --- lib/chef/provider/powershell_script.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/chef/provider/powershell_script.rb') 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 -- cgit v1.2.1