Skip to content

scripts do not exit with correct exit code when sys.exit() is used #2861

@dandrake

Description

@dandrake

If I call sys.exit() from a Sage script, the script exits but not with the correct exit code. For example, the script

import sys

print 'exiting!'
sys.exit(1)

exits with exit code 0 when run from Sage:

$ sage exitcode.sage 
exiting!
1
$ echo $?
0

(the 1 gets printed because the preparser turns it into a Sage integer, and Python prints out anything except Python integers.) But the same script works properly when run from Python:

$ python exitcode.sage
exiting!
$ echo $?
1

I don't know if this is Sage or IPython behavior, but having this work would be really useful.

Component: user interface

Issue created by migration from https://trac.sagemath.org/ticket/2861

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions