You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] command NAME ARGS expands its arguments twice, so substitutions run twice #364
Same as bash 5.2.15, where each argument is expanded once:
x
once
1 1
got: l1
l2
Actual Behavior
x
once
once
2 2
got:
The substitution runs twice. In the third case the first run consumes stdin and its result is thrown away, so the command gets an empty string, with exit 0 and nothing on stderr.
Additional Context
This is the command half of #261, which noted that command "has the same expand-then-dispatch shape and is worth checking". #352 fixes the exec arm only and will close #261.
src/exec.rs:3516 (main @ dbb6189) expands the arguments to look for -v/-V, then src/exec.rs:3550-3554 passes the unexpanded words to execute_pipeline, which expands them again:
let args = expand_words(os.clone(), proc,&pipeline[0].args[1..]).await;
...
let fake_cmd = parser::Command{env: pipeline[0].env.clone(),args: pipeline[0].args[1..].to_vec(),redirects: pipeline[0].redirects.clone(),};
builtin command echo $(...) is affected the same way. command -v / -V return before the second expansion and are not affected.
Possible Solution
The same change #352 makes for exec: build fake_cmd.args from the already expanded args, each as a single WordPart::SingleQuoted word. A differential case next to exec_expands_args_once.sh would cover it.
Activity