{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/comments/70376509","id":70376509,"diff_hunk":"@@ -47,6 +47,22 @@ class PowerShellManager; end\n       expect(result[:exitcode]).to eq(1)\n     end\n \n+    it \"should return the exitcode of the last command to set an exit code\" do\n+      result = manager.execute(\"$LASTEXITCODE = 0; write-output 'foo'; cmd.exe /c 'exit 99'; write-output 'bar'\")\n+\n+      # STDERR is interpolating the newlines thus it's \\n instead of the usual Windows \\r\\n\n+      expect(result[:stdout]).to eq(\"foo\\r\\nbar\\r\\n\")\n+      expect(result[:exitcode]).to eq(99)","path":"spec/integration/puppet_x/puppetlabs/powershell_manager_spec.rb","position":9,"original_position":9,"commit_id":"4d0ed64674cd02912bd5436c6fd91bca1cac2cda","original_commit_id":"4d0ed64674cd02912bd5436c6fd91bca1cac2cda","user":{"login":"Iristyle","id":394081,"avatar_url":"https://avatars.githubusercontent.com/u/394081?v=3","gravatar_id":"","url":"https://api.github.com/users/Iristyle","html_url":"https://github.com/Iristyle","followers_url":"https://api.github.com/users/Iristyle/followers","following_url":"https://api.github.com/users/Iristyle/following{/other_user}","gists_url":"https://api.github.com/users/Iristyle/gists{/gist_id}","starred_url":"https://api.github.com/users/Iristyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Iristyle/subscriptions","organizations_url":"https://api.github.com/users/Iristyle/orgs","repos_url":"https://api.github.com/users/Iristyle/repos","events_url":"https://api.github.com/users/Iristyle/events{/privacy}","received_events_url":"https://api.github.com/users/Iristyle/received_events","type":"User","site_admin":false},"body":"This might be an unexpected result now, but arguably it is \"correct\".\r\n\r\nWorth discussing @puppetlabs/windows ","created_at":"2016-07-12T04:43:31Z","updated_at":"2016-07-12T04:43:31Z","html_url":"https://github.com/puppetlabs/puppetlabs-powershell/pull/129#discussion_r70376509","pull_request_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/comments/70376509"},"html":{"href":"https://github.com/puppetlabs/puppetlabs-powershell/pull/129#discussion_r70376509"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/129","id":77059631,"html_url":"https://github.com/puppetlabs/puppetlabs-powershell/pull/129","diff_url":"https://github.com/puppetlabs/puppetlabs-powershell/pull/129.diff","patch_url":"https://github.com/puppetlabs/puppetlabs-powershell/pull/129.patch","issue_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/issues/129","number":129,"state":"open","locked":false,"title":"(MODULES-3399) Exit user scripts via $LASTEXITCODE ","user":{"login":"Iristyle","id":394081,"avatar_url":"https://avatars.githubusercontent.com/u/394081?v=3","gravatar_id":"","url":"https://api.github.com/users/Iristyle","html_url":"https://github.com/Iristyle","followers_url":"https://api.github.com/users/Iristyle/followers","following_url":"https://api.github.com/users/Iristyle/following{/other_user}","gists_url":"https://api.github.com/users/Iristyle/gists{/gist_id}","starred_url":"https://api.github.com/users/Iristyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Iristyle/subscriptions","organizations_url":"https://api.github.com/users/Iristyle/orgs","repos_url":"https://api.github.com/users/Iristyle/repos","events_url":"https://api.github.com/users/Iristyle/events{/privacy}","received_events_url":"https://api.github.com/users/Iristyle/received_events","type":"User","site_admin":false},"body":" - Previously in v1 of the module, if the call operator & was used to\r\n   execute an external script, and that script performed an \"exit 1\",\r\n   that exit code would propagate.  This technique could be used within\r\n   an unless or onlyif to ensure idempotent behavior like:\r\n\r\n   unless => '& exit-one.ps1'\r\n\r\n   This would allow users to create fully reusable PowerShell scripts\r\n   that could be invoked outside of the Puppet environment during\r\n   development and testing.\r\n\r\n - Since code is invoked differently in the v2 module, that behavior\r\n   changed, and any exit codes set externally in a PS script invoked by\r\n   the call operator are not propagating. The custom PowerShell host\r\n   SetShouldExit method is not being triggered in this situation.\r\n\r\n   This commit restores the old behavior by performing an\r\n   exit $LASTEXITCODE after executing the user code.\r\n\r\n   NOTE: this has the side effect of returning an exit code that may be\r\n   unexpected, based on the last external command invoked by PowerShell.\r\n\r\n   Users will be expected to understand this when developing longer more\r\n   complex scripts.","created_at":"2016-07-12T04:23:22Z","updated_at":"2016-07-12T04:43:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"edcf6a48b62ef40219c149220df324522f49c8bc","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/129/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/129/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/issues/129/comments","statuses_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/statuses/4d0ed64674cd02912bd5436c6fd91bca1cac2cda","head":{"label":"Iristyle:ticket/stable/MODULES-3399-set-call-operator-exit-status","ref":"ticket/stable/MODULES-3399-set-call-operator-exit-status","sha":"4d0ed64674cd02912bd5436c6fd91bca1cac2cda","user":{"login":"Iristyle","id":394081,"avatar_url":"https://avatars.githubusercontent.com/u/394081?v=3","gravatar_id":"","url":"https://api.github.com/users/Iristyle","html_url":"https://github.com/Iristyle","followers_url":"https://api.github.com/users/Iristyle/followers","following_url":"https://api.github.com/users/Iristyle/following{/other_user}","gists_url":"https://api.github.com/users/Iristyle/gists{/gist_id}","starred_url":"https://api.github.com/users/Iristyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Iristyle/subscriptions","organizations_url":"https://api.github.com/users/Iristyle/orgs","repos_url":"https://api.github.com/users/Iristyle/repos","events_url":"https://api.github.com/users/Iristyle/events{/privacy}","received_events_url":"https://api.github.com/users/Iristyle/received_events","type":"User","site_admin":false},"repo":{"id":36790021,"name":"puppetlabs-powershell","full_name":"Iristyle/puppetlabs-powershell","owner":{"login":"Iristyle","id":394081,"avatar_url":"https://avatars.githubusercontent.com/u/394081?v=3","gravatar_id":"","url":"https://api.github.com/users/Iristyle","html_url":"https://github.com/Iristyle","followers_url":"https://api.github.com/users/Iristyle/followers","following_url":"https://api.github.com/users/Iristyle/following{/other_user}","gists_url":"https://api.github.com/users/Iristyle/gists{/gist_id}","starred_url":"https://api.github.com/users/Iristyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Iristyle/subscriptions","organizations_url":"https://api.github.com/users/Iristyle/orgs","repos_url":"https://api.github.com/users/Iristyle/repos","events_url":"https://api.github.com/users/Iristyle/events{/privacy}","received_events_url":"https://api.github.com/users/Iristyle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Iristyle/puppetlabs-powershell","description":"powershell provider for the Puppet exec resource type","fork":true,"url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell","forks_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/forks","keys_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/teams","hooks_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/hooks","issue_events_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/issues/events{/number}","events_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/events","assignees_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/assignees{/user}","branches_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/branches{/branch}","tags_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/tags","blobs_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/git/refs{/sha}","trees_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/statuses/{sha}","languages_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/languages","stargazers_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/stargazers","contributors_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/contributors","subscribers_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/subscribers","subscription_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/subscription","commits_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/commits{/sha}","git_commits_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/git/commits{/sha}","comments_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/comments{/number}","issue_comment_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/issues/comments{/number}","contents_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/contents/{+path}","compare_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/merges","archive_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/downloads","issues_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/issues{/number}","pulls_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/pulls{/number}","milestones_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/milestones{/number}","notifications_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/labels{/name}","releases_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/releases{/id}","deployments_url":"https://api.github.com/repos/Iristyle/puppetlabs-powershell/deployments","created_at":"2015-06-03T08:23:18Z","updated_at":"2016-05-05T23:48:17Z","pushed_at":"2016-07-12T04:42:39Z","git_url":"git://github.com/Iristyle/puppetlabs-powershell.git","ssh_url":"git@github.com:Iristyle/puppetlabs-powershell.git","clone_url":"https://github.com/Iristyle/puppetlabs-powershell.git","svn_url":"https://github.com/Iristyle/puppetlabs-powershell","homepage":"forge.puppetlabs.com/puppetlabs/powershell","size":22115,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"puppetlabs:stable","ref":"stable","sha":"c58158ff2d46428d2866dd5f319b43b02bf0af49","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":7831726,"name":"puppetlabs-powershell","full_name":"puppetlabs/puppetlabs-powershell","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/puppetlabs-powershell","description":"powershell provider for the Puppet exec resource type","fork":false,"url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell","forks_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/forks","keys_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/teams","hooks_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/events","assignees_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/tags","blobs_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/subscription","commits_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/merges","archive_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/downloads","issues_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/releases{/id}","deployments_url":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/deployments","created_at":"2013-01-26T01:16:29Z","updated_at":"2016-06-30T14:03:35Z","pushed_at":"2016-07-12T04:42:39Z","git_url":"git://github.com/puppetlabs/puppetlabs-powershell.git","ssh_url":"git@github.com:puppetlabs/puppetlabs-powershell.git","clone_url":"https://github.com/puppetlabs/puppetlabs-powershell.git","svn_url":"https://github.com/puppetlabs/puppetlabs-powershell","homepage":"forge.puppetlabs.com/puppetlabs/powershell","size":22292,"stargazers_count":30,"watchers_count":30,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":44,"mirror_url":null,"open_issues_count":6,"forks":44,"open_issues":6,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/129"},"html":{"href":"https://github.com/puppetlabs/puppetlabs-powershell/pull/129"},"issue":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/issues/129"},"comments":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-powershell/statuses/4d0ed64674cd02912bd5436c6fd91bca1cac2cda"}}}}
{"actor":{"display_login":"Iristyle"}}