mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Merge pull request #3307 from xonsh/fnf_exit_1
Non-zero exit code when script path not found
This commit is contained in:
commit
7829074d9a
3 changed files with 39 additions and 0 deletions
31
news/fnf_exit_1.rst
Normal file
31
news/fnf_exit_1.rst
Normal file
|
@ -0,0 +1,31 @@
|
|||
**Added:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Changed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* ``xonsh`` will return a non-zero exit code if it is run in file mode and
|
||||
cannot find the file specified, e.g.
|
||||
|
||||
.. code-block::
|
||||
|
||||
$ xonsh thisfiledoesntexist.xsh
|
||||
xonsh: thisfiledoesntexist.xsh: No such file or directory.
|
||||
$ _.returncode
|
||||
1
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -186,3 +186,9 @@ def test_xonsh_failback_script_from_file(shell, monkeypatch, monkeypatch_stderr)
|
|||
with pytest.raises(Exception):
|
||||
xonsh.main.main()
|
||||
assert len(checker) == 0
|
||||
|
||||
|
||||
def test_xonsh_no_file_returncode(shell, monkeypatch, monkeypatch_stderr):
|
||||
monkeypatch.setattr(sys, "argv", ["xonsh", "foobazbarzzznotafileatall.xsh"])
|
||||
with pytest.raises(SystemExit):
|
||||
xonsh.main.main()
|
||||
|
|
|
@ -447,6 +447,8 @@ def main_xonsh(args):
|
|||
)
|
||||
else:
|
||||
print("xonsh: {0}: No such file or directory.".format(args.file))
|
||||
events.on_exit.fire()
|
||||
sys.exit(1)
|
||||
elif args.mode == XonshMode.script_from_stdin:
|
||||
# run a script given on stdin
|
||||
code = sys.stdin.read()
|
||||
|
|
Loading…
Add table
Reference in a new issue