-
-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xonsh returns zero exit code when a command fails in a script #3309
Comments
Closed via #3307 |
#3307 couldn't have possibly fixed this problem. I can't reopen this issue, but the bug is most probably still there. |
@gforsyth no worries! I figured that was the case. |
Hi @certik - I can't for the life of me reproduce this with a simpler example. Consider the following bad.xsh scripts:
or
or
At the command line, all of these produce: scopatz@artemis ~/temp $ xonsh bad.xsh && echo OK
Traceback (most recent call last):
File "/home/scopatz/.local/bin/xonsh", line 4, in <module>
main()
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 24011, in main
_failback_to_other_shells(args, err)
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 23975, in _failback_to_other_shells
raise err
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 24009, in main
return main_xonsh(args)
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 24053, in main_xonsh
args.file, shell.execer, glb=shell.ctx, loc=None, mode="exec"
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 3038, in run_script_with_cache
run_compiled_code(ccode, glb, loc, mode)
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 2943, in run_compiled_code
func(code, glb, loc)
File "bad.xsh", line 9, in <module>
python -c "import sys; sys.exit(42)"
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 22466, in subproc_captured_hiddenobject
return run_subproc(cmds, captured="hiddenobject")
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 22429, in run_subproc
command.end()
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 15671, in end
self._end(tee_output=tee_output)
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 15690, in _end
self._raise_subproc_error()
File "/home/scopatz/.local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 15816, in _raise_subproc_error
raise subprocess.CalledProcessError(rtn, spec.args, output=self.output)
subprocess.CalledProcessError: Command '['python', '-c', 'import sys; sys.exit(42)']' returned non-zero exit status 42.
scopatz@artemis ~/temp $ _.returncode
1 Are you sure the |
Here is how to reproduce this very important bug. Create this file #include <iostream>
int main() {
throw std::runtime_error("xx");
return 0;
} Compile using:
And test that it returns a non-zero exit code:
Now call this as part of a Xonsh script: #!/usr/bin/env xonsh
$RAISE_SUBPROC_ERROR = True
trace on
./a.out as follows:
As you can see, Xonsh returns a zero exit value. |
@certik - we figured this out, right? but did a fix go in? |
I don't think a fix went in.
…On Sat, Feb 29, 2020, at 5:17 PM, Anthony Scopatz wrote:
@certik <https://github.com/certik> - we figured this out, right? but
did a fix go in?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3309?email_source=notifications&email_token=AAAFAWD5CVXSQQ3CMVEBJVLRFGSQ5A5CNFSM4IVBEIRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENMKWPA#issuecomment-593013564>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAFAWHTRRDCIVEYNYCX23TRFGSQ5ANCNFSM4IVBEIRA>.
|
I found the fix on a branch! Just need to add tests |
Potential fix in #3465 |
I haven't had time to triage it yet, but here is what I executed:
The C++ code exited with an uncaught exception which generates a non-zero exit code as can be verified by:
And yet Xonsh returns zero exit code and the "OK" gets printed.
This is a serious issue as I use Xonsh on a CI and I need it to fail when an exception occurs in my C++ program.
Here is the
ci/build.xsh
(as you can see I enabled the equivalent ofset -e
):The text was updated successfully, but these errors were encountered: