{"action":"created","comment":{"url":"https://api.github.com/repos/scopatz/xonsh/pulls/comments/55234948","id":55234948,"diff_hunk":"@@ -635,17 +654,40 @@ def run_subproc(cmds, captured=True):\n             output = output.replace('\\r\\n', '\\n')\n         else:\n             hist.last_cmd_out = output\n+        if captured == 'object' and prev_proc.stderr not in {None, sys.stderr}:\n+            errout = prev_proc.stderr.read()\n+            errout = errout.decode(encoding=ENV.get('XONSH_ENCODING'),\n+                                   errors=ENV.get('XONSH_ENCODING_ERRORS'))\n+            errout = errout.replace('\\r\\n', '\\n')\n+            procinfo['stderr'] = errout\n+\n     if not prev_is_proxy and hist.last_cmd_rtn > 0 and ENV.get('RAISE_SUBPROC_ERROR'):\n         raise CalledProcessError(hist.last_cmd_rtn, aliased_cmd, output=output)\n-    if captured:\n+    if captured=='stdout':\n         return output\n+    elif captured=='object':","path":"xonsh/built_ins.py","position":154,"original_position":154,"commit_id":"72cd7d4fd9dc01e03de72069689303e0d2e8cf20","original_commit_id":"72cd7d4fd9dc01e03de72069689303e0d2e8cf20","user":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"body":"PEP8","created_at":"2016-03-07T17:04:34Z","updated_at":"2016-03-07T17:04:34Z","html_url":"https://github.com/scopatz/xonsh/pull/702#discussion_r55234948","pull_request_url":"https://api.github.com/repos/scopatz/xonsh/pulls/702","_links":{"self":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/comments/55234948"},"html":{"href":"https://github.com/scopatz/xonsh/pull/702#discussion_r55234948"},"pull_request":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/702"}}},"pull_request":{"url":"https://api.github.com/repos/scopatz/xonsh/pulls/702","id":60611429,"html_url":"https://github.com/scopatz/xonsh/pull/702","diff_url":"https://github.com/scopatz/xonsh/pull/702.diff","patch_url":"https://github.com/scopatz/xonsh/pull/702.patch","issue_url":"https://api.github.com/repos/scopatz/xonsh/issues/702","number":702,"state":"open","locked":false,"title":"Subproc return values","user":{"login":"adqm","id":549404,"avatar_url":"https://avatars.githubusercontent.com/u/549404?v=3","gravatar_id":"","url":"https://api.github.com/users/adqm","html_url":"https://github.com/adqm","followers_url":"https://api.github.com/users/adqm/followers","following_url":"https://api.github.com/users/adqm/following{/other_user}","gists_url":"https://api.github.com/users/adqm/gists{/gist_id}","starred_url":"https://api.github.com/users/adqm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adqm/subscriptions","organizations_url":"https://api.github.com/users/adqm/orgs","repos_url":"https://api.github.com/users/adqm/repos","events_url":"https://api.github.com/users/adqm/events{/privacy}","received_events_url":"https://api.github.com/users/adqm/received_events","type":"User","site_admin":false},"body":"This is a modification/update of some old code I wrote, which implements @piotrjurkiewicz 's suggestion from #701, to make captured subprocesses return a number representing their return code, instead of returning `None`.\r\n\r\nThis also implements an alternative subproc function that _does_ always return `None`, which is used when a line is forced into subproc mode so that we don't see the extra numbers showing up when running commands interactively.\r\n\r\nSome examples:\r\n```\r\nhartz@lappy-514 ~/xonsh $ ls a> /dev/null\r\nhartz@lappy-514 ~/xonsh $ $[ls a> /dev/null]\r\n0\r\nhartz@lappy-514 ~/xonsh $ x = $[/bin/true], $[/bin/false]\r\nhartz@lappy-514 ~/xonsh $ x\r\n(0, 1)\r\nhartz@lappy-514 ~/xonsh $ [$[ls @(i) a> /dev/null] for i in ['xonsh', 'nonexistent', 'tests']]\r\n[0, 2, 0]\r\nhartz@lappy-514 ~/xonsh $ def foo(x):\r\n.........................     return $[ls @(x)]\r\n......................... \r\nhartz@lappy-514 ~/xonsh $ y = foo('xonsh')\r\naliases.py       execer.py          main.py          readline_shell.py\r\nansi_colors.py   execer.py~         mplhooks.py      replay.py\r\nast.py           foreign_shells.py  openpy.py        shell.py\r\nast.py~          history.py         parser.py        teepty.py\r\nbase_shell.py    imphooks.py        parsers          timings.py\r\nbuilt_ins.py     __init__.py        parser_table.py  tools.py\r\nbuilt_ins.py~    inspectors.py      pretty.py        tracer.py\r\ncompleter.py     jobs.py            proc.py          vox.py\r\ndiff_history.py  jupyter_kernel.py  ptk              wizard.py\r\ndirstack.py      lazyjson.py        __pycache__      xonfig.py\r\nenviron.py       lexer.py           pyghooks.py\r\nhartz@lappy-514 ~/xonsh $ y\r\n0\r\n```\r\n\r\nAlso tries to fix another bug I noticed, involving comparing `None` against `0` when checking whether to raise an exception near the end of `run_subproc`.","created_at":"2016-02-25T01:44:04Z","updated_at":"2016-03-07T17:04:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"81a6c7834212f629ff6727aaddcc7930bde964fd","assignee":null,"milestone":{"url":"https://api.github.com/repos/scopatz/xonsh/milestones/2","html_url":"https://github.com/scopatz/xonsh/milestones/v0.3","labels_url":"https://api.github.com/repos/scopatz/xonsh/milestones/2/labels","id":1302567,"number":2,"title":"v0.3","description":"","creator":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"open_issues":96,"closed_issues":257,"state":"open","created_at":"2015-09-12T18:28:59Z","updated_at":"2016-03-07T16:53:44Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/scopatz/xonsh/pulls/702/commits","review_comments_url":"https://api.github.com/repos/scopatz/xonsh/pulls/702/comments","review_comment_url":"https://api.github.com/repos/scopatz/xonsh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scopatz/xonsh/issues/702/comments","statuses_url":"https://api.github.com/repos/scopatz/xonsh/statuses/72cd7d4fd9dc01e03de72069689303e0d2e8cf20","head":{"label":"adqm:subproc_return_values","ref":"subproc_return_values","sha":"72cd7d4fd9dc01e03de72069689303e0d2e8cf20","user":{"login":"adqm","id":549404,"avatar_url":"https://avatars.githubusercontent.com/u/549404?v=3","gravatar_id":"","url":"https://api.github.com/users/adqm","html_url":"https://github.com/adqm","followers_url":"https://api.github.com/users/adqm/followers","following_url":"https://api.github.com/users/adqm/following{/other_user}","gists_url":"https://api.github.com/users/adqm/gists{/gist_id}","starred_url":"https://api.github.com/users/adqm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adqm/subscriptions","organizations_url":"https://api.github.com/users/adqm/orgs","repos_url":"https://api.github.com/users/adqm/repos","events_url":"https://api.github.com/users/adqm/events{/privacy}","received_events_url":"https://api.github.com/users/adqm/received_events","type":"User","site_admin":false},"repo":{"id":32187841,"name":"xonsh","full_name":"adqm/xonsh","owner":{"login":"adqm","id":549404,"avatar_url":"https://avatars.githubusercontent.com/u/549404?v=3","gravatar_id":"","url":"https://api.github.com/users/adqm","html_url":"https://github.com/adqm","followers_url":"https://api.github.com/users/adqm/followers","following_url":"https://api.github.com/users/adqm/following{/other_user}","gists_url":"https://api.github.com/users/adqm/gists{/gist_id}","starred_url":"https://api.github.com/users/adqm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adqm/subscriptions","organizations_url":"https://api.github.com/users/adqm/orgs","repos_url":"https://api.github.com/users/adqm/repos","events_url":"https://api.github.com/users/adqm/events{/privacy}","received_events_url":"https://api.github.com/users/adqm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adqm/xonsh","description":"xonsh is a Python-ish, BASHwards-compatible shell.","fork":true,"url":"https://api.github.com/repos/adqm/xonsh","forks_url":"https://api.github.com/repos/adqm/xonsh/forks","keys_url":"https://api.github.com/repos/adqm/xonsh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adqm/xonsh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adqm/xonsh/teams","hooks_url":"https://api.github.com/repos/adqm/xonsh/hooks","issue_events_url":"https://api.github.com/repos/adqm/xonsh/issues/events{/number}","events_url":"https://api.github.com/repos/adqm/xonsh/events","assignees_url":"https://api.github.com/repos/adqm/xonsh/assignees{/user}","branches_url":"https://api.github.com/repos/adqm/xonsh/branches{/branch}","tags_url":"https://api.github.com/repos/adqm/xonsh/tags","blobs_url":"https://api.github.com/repos/adqm/xonsh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adqm/xonsh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adqm/xonsh/git/refs{/sha}","trees_url":"https://api.github.com/repos/adqm/xonsh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adqm/xonsh/statuses/{sha}","languages_url":"https://api.github.com/repos/adqm/xonsh/languages","stargazers_url":"https://api.github.com/repos/adqm/xonsh/stargazers","contributors_url":"https://api.github.com/repos/adqm/xonsh/contributors","subscribers_url":"https://api.github.com/repos/adqm/xonsh/subscribers","subscription_url":"https://api.github.com/repos/adqm/xonsh/subscription","commits_url":"https://api.github.com/repos/adqm/xonsh/commits{/sha}","git_commits_url":"https://api.github.com/repos/adqm/xonsh/git/commits{/sha}","comments_url":"https://api.github.com/repos/adqm/xonsh/comments{/number}","issue_comment_url":"https://api.github.com/repos/adqm/xonsh/issues/comments{/number}","contents_url":"https://api.github.com/repos/adqm/xonsh/contents/{+path}","compare_url":"https://api.github.com/repos/adqm/xonsh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adqm/xonsh/merges","archive_url":"https://api.github.com/repos/adqm/xonsh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adqm/xonsh/downloads","issues_url":"https://api.github.com/repos/adqm/xonsh/issues{/number}","pulls_url":"https://api.github.com/repos/adqm/xonsh/pulls{/number}","milestones_url":"https://api.github.com/repos/adqm/xonsh/milestones{/number}","notifications_url":"https://api.github.com/repos/adqm/xonsh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adqm/xonsh/labels{/name}","releases_url":"https://api.github.com/repos/adqm/xonsh/releases{/id}","deployments_url":"https://api.github.com/repos/adqm/xonsh/deployments","created_at":"2015-03-14T00:10:49Z","updated_at":"2015-05-07T12:12:54Z","pushed_at":"2016-03-07T10:44:24Z","git_url":"git://github.com/adqm/xonsh.git","ssh_url":"git@github.com:adqm/xonsh.git","clone_url":"https://github.com/adqm/xonsh.git","svn_url":"https://github.com/adqm/xonsh","homepage":"http://xonsh.org","size":3842,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"scopatz:master","ref":"master","sha":"8c66dfc725b2831b5a415afaf19ad01608000cc2","user":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"repo":{"id":29620400,"name":"xonsh","full_name":"scopatz/xonsh","owner":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scopatz/xonsh","description":"xonsh is a Python-ish, BASHwards-facing shell.","fork":false,"url":"https://api.github.com/repos/scopatz/xonsh","forks_url":"https://api.github.com/repos/scopatz/xonsh/forks","keys_url":"https://api.github.com/repos/scopatz/xonsh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scopatz/xonsh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scopatz/xonsh/teams","hooks_url":"https://api.github.com/repos/scopatz/xonsh/hooks","issue_events_url":"https://api.github.com/repos/scopatz/xonsh/issues/events{/number}","events_url":"https://api.github.com/repos/scopatz/xonsh/events","assignees_url":"https://api.github.com/repos/scopatz/xonsh/assignees{/user}","branches_url":"https://api.github.com/repos/scopatz/xonsh/branches{/branch}","tags_url":"https://api.github.com/repos/scopatz/xonsh/tags","blobs_url":"https://api.github.com/repos/scopatz/xonsh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scopatz/xonsh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scopatz/xonsh/git/refs{/sha}","trees_url":"https://api.github.com/repos/scopatz/xonsh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scopatz/xonsh/statuses/{sha}","languages_url":"https://api.github.com/repos/scopatz/xonsh/languages","stargazers_url":"https://api.github.com/repos/scopatz/xonsh/stargazers","contributors_url":"https://api.github.com/repos/scopatz/xonsh/contributors","subscribers_url":"https://api.github.com/repos/scopatz/xonsh/subscribers","subscription_url":"https://api.github.com/repos/scopatz/xonsh/subscription","commits_url":"https://api.github.com/repos/scopatz/xonsh/commits{/sha}","git_commits_url":"https://api.github.com/repos/scopatz/xonsh/git/commits{/sha}","comments_url":"https://api.github.com/repos/scopatz/xonsh/comments{/number}","issue_comment_url":"https://api.github.com/repos/scopatz/xonsh/issues/comments{/number}","contents_url":"https://api.github.com/repos/scopatz/xonsh/contents/{+path}","compare_url":"https://api.github.com/repos/scopatz/xonsh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scopatz/xonsh/merges","archive_url":"https://api.github.com/repos/scopatz/xonsh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scopatz/xonsh/downloads","issues_url":"https://api.github.com/repos/scopatz/xonsh/issues{/number}","pulls_url":"https://api.github.com/repos/scopatz/xonsh/pulls{/number}","milestones_url":"https://api.github.com/repos/scopatz/xonsh/milestones{/number}","notifications_url":"https://api.github.com/repos/scopatz/xonsh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scopatz/xonsh/labels{/name}","releases_url":"https://api.github.com/repos/scopatz/xonsh/releases{/id}","deployments_url":"https://api.github.com/repos/scopatz/xonsh/deployments","created_at":"2015-01-21T22:05:27Z","updated_at":"2016-03-07T00:37:05Z","pushed_at":"2016-03-07T16:52:55Z","git_url":"git://github.com/scopatz/xonsh.git","ssh_url":"git@github.com:scopatz/xonsh.git","clone_url":"https://github.com/scopatz/xonsh.git","svn_url":"https://github.com/scopatz/xonsh","homepage":"http://xon.sh","size":4645,"stargazers_count":747,"watchers_count":747,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":90,"mirror_url":null,"open_issues_count":109,"forks":90,"open_issues":109,"watchers":747,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/702"},"html":{"href":"https://github.com/scopatz/xonsh/pull/702"},"issue":{"href":"https://api.github.com/repos/scopatz/xonsh/issues/702"},"comments":{"href":"https://api.github.com/repos/scopatz/xonsh/issues/702/comments"},"review_comments":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/702/comments"},"review_comment":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/702/commits"},"statuses":{"href":"https://api.github.com/repos/scopatz/xonsh/statuses/72cd7d4fd9dc01e03de72069689303e0d2e8cf20"}}}}