[issue5680] Simulate command-line arguments for program run in IDLE

Terry J. Reedy report at bugs.python.org
Sat Jun 1 21:20:53 EDT 2019


Terry J. Reedy <tjreedy at udel.edu> added the comment:

My suspicion about posix=False was wrong.

>>> shlex.split(''' 1 "'a' 'b'" ''', posix=False)
['1', '"\'a\' \'b\'"']  # len(...[1]) = 9
>>> shlex.split(''' 1 '"a" "b"' ''')
['1', '"a" "b"']  # len = 7
f:\dev\3x>py -c "import sys; print(sys.argv)" 1 "'a' 'b'"
['-c', '1', "'a' 'b'"]  # Matches 'True'

>>> shlex.split(''' 1 '"a" "b"' ''', posix=False)
['1', '\'"a" "b"\'']
>>> shlex.split(''' 1 '"a" "b"' ''')
['1', '"a" "b"']  # Similar difference
f:\dev\3x>py -c "import sys; print(sys.argv)" 1 '"a" "b"'
['-c', '1', "'a", "b'"]  # crazy inversion and 3 args, matches neither

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue5680>
_______________________________________


More information about the Python-bugs-list mailing list