File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ def extend_parser(parser: argparse.ArgumentParser):
2323 """
2424 parser .add_argument (
2525 "file" ,
26- nargs = "? " ,
26+ nargs = "* " ,
2727 help = "execute the given file as sage code" ,
2828 )
2929
@@ -32,13 +32,16 @@ def __init__(self, options: CliOptions):
3232 Initialize the command.
3333 """
3434 self .options = options
35+ # shift sys.argv for compatibility with the old sage bash script and python command when consuming arguments from the command line
36+ import sys
37+ del sys .argv [0 ]
3538
3639 def run (self ) -> int :
3740 r"""
3841 Execute the given command.
3942 """
40- input_file = preparse_file_named (self .options .file ) if self .options .file .endswith ('.sage' ) else self .options .file
41- if self .options .file .endswith ('.pyx' ) or self .options .file .endswith ('.spyx' ):
43+ input_file = preparse_file_named (self .options .file [ 0 ] ) if self .options .file [ 0 ] .endswith ('.sage' ) else self .options .file [ 0 ]
44+ if self .options .file [ 0 ] .endswith ('.pyx' ) or self .options .file [ 0 ] .endswith ('.spyx' ):
4245 s = load_cython (input_file )
4346 eval (compile (s , tmp_filename (), 'exec' ), sage_globals ())
4447 else :
You can’t perform that action at this time.
0 commit comments