unix: Improve command line argument processing.

Per CPython everything which comes after the command, module or file
argument is not an option for the interpreter itself.  Hence the processing
of options should stop when encountering those, and the remainder be passed
as sys.argv.  Note the latter was already the case for a module or file but
not for a command.

This fixes issues like 'micropython myfile.py -h' showing the help and
exiting instead of passing '-h' as sys.argv[1], likewise for
'-X <something>' being treated as a special option no matter where it
occurs on the command line.
This commit is contained in:
stijn
2021-04-06 20:40:31 +02:00
committed by Damien George
parent 4f53f462ca
commit a66286f3a0
3 changed files with 10 additions and 6 deletions

View File

@@ -1,2 +1,2 @@
# cmdline: -c print("test") -i
# cmdline: -i -c print("test")
# -c option combined with -i option results in REPL

View File

@@ -1,6 +1,6 @@
test
MicroPython \.\+ version
Use \.\+
>>> # cmdline: -c print("test") -i
>>> # cmdline: -i -c print("test")
>>> # -c option combined with -i option results in REPL
>>>