Why does command injection not work in
$ bash -c "ls \$1" bash '.; echo hello'
ls: cannot access '.;': No such file or directory
ls: cannot access 'echo': No such file or directory
ls: cannot access 'hello': No such file or directory
while
$ bash -c "eval ls \$1" bash '.; echo hello'
works?
In the first command, does the first bash perform parameter expansion on $1, word splitting on the result of expanding $1, and then execute the commands?
Thanks.
Originated from Ways to provide arguments to a command executed by `bash -c`
related to Why is this code injection not working?