[issue39692] Subprocess using list vs string
Jonny Weese
report at bugs.python.org
Thu Feb 20 13:46:18 EST 2020
Jonny Weese <jweese at gmail.com> added the comment:
> So the command_string provided (the first word or the first quoted expression) is interpreted as a shell program, and this program is invoked with the remaining words as its arguments.
Correct.
> As you say, simply slapping quotes around all the args produces a subtle difference: the arg in the position of `$0` is used as an actual positional parameter in one case, and as the shell name in the other case
It is not quite just a shifting of the positional args.
$ bash -c 'f() { printf "%s\n"; }; f "$@"' - foo bar baz
=> "From a string, read this bash script, which defines a function f and then invokes f on all of its arguments. Now invoke that script with an executable name of "-" and the arguments "foo" "bar" and "baz".
$ bash -c 'f() { printf "%s\n"; }; f "$@" - foo bar baz'
=> "From a string, read this bash script, which defines f and then invokes f on all the script arguments as well as "-" "foo" "bar" and "baz". Then invoke that script with no other arguments."
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39692>
_______________________________________
More information about the Python-bugs-list
mailing list