New submission from Jason Williams <jasonjwwilli...@gmail.com>:
Passing arguments to a Python script using an environment variable like: export en_auth="--arg1 test --arg2 \"$(<private_key.pem)\"" ./test.py $en_auth Incorrectly treats the value of arg2 as another argument rather than a value because the file value being inserted starts with "--": -----BEGIN EC PARAMETERS----- BggqhkjOPQMBBw== -----END EC PARAMETERS----- sys.argv parses it as: ['--arg1', 'test', '--arg2', '"-----BEGIN', 'EC', 'PARAMETERS-----', 'BggqhkjOPQMBBw==', '-----END', 'EC', 'PARAMETERS-----"'] If the arguments are provided directly to the script it parses correctly: ./test.py --arg1 test --arg2 "$(<private_key.pem)" ['--base-api-url', 'test', '--provisioning-device-private-key', '-----BEGIN EC PARAMETERS-----'] This looks like two bugs...sys.argv is splitting the value incorrectly because its ignoring the quoting, and argparse is treating values that start with -- as arguments. ---------- files: test.py messages: 385366 nosy: Jason Williams priority: normal severity: normal status: open title: sys.argv incorrectly parses command lines with args in environment variables. versions: Python 3.8 Added file: https://bugs.python.org/file49753/test.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42983> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com