Jonny Weese <[email protected]> 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 <[email protected]>
<https://bugs.python.org/issue39692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com