3 ms·
> While the double-hyphens are assigned to `$0` in this example, they also serve to halt bash's interpretation of command line switches once encountered. For ex
by aidenn0 1y ago
> While the double-hyphens are assigned to `$0` in this example, they also serve to halt bash's interpretation of command line switches once encountered. For example...
That is contrary to both the bash manpage and my tests. Here's the simplest test.
bash -c 'false; echo hi' -e
Will print "hi" because -e is not interpreted as a command line switch despite no "--" being present (nothing after the "-c" is) while
bash -e -c 'false; echo hi'
Does what one expects.
Or another way of putting it:
bash -c '/bin/ps "$1"' foo "-l"
Will work exactly the same as
bash -c '/bin/ps "$1"' -- "-l"
Since the "--" has zero function on this commandline except as a placeholder for argv[0].
- AdieuToLogic 1y agoYou are right. The undesired behavior I observed in my example was not related to `bash` and arguments after `-c "command string"`, but instead how `ps` on the platform I use behaves when invoked thusly: /bin/ps ''
- deleted 1y ago[deleted]