Message362342
> 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." |
|
Date |
User |
Action |
Args |
2020-02-20 18:46:18 | jweese | set | recipients:
+ jweese, nik-sm |
2020-02-20 18:46:18 | jweese | set | messageid: <1582224378.4.0.954203381457.issue39692@roundup.psfhosted.org> |
2020-02-20 18:46:18 | jweese | link | issue39692 messages |
2020-02-20 18:46:18 | jweese | create | |
|