When running bash as:
bash -s foo bar
"$@" is not available inside .bashrc. Same for $ENV (POSIX
conformance issue?), $BASH_ENV, or ~/.bash_profile (with bash
--login -s).
In the case of bash -c, that also affects $0.
ksh88, ksh93, mksh, dash, zsh, posh, busybox sh can access $@ in
$ENV
Reproduce it with:
$ echo 'echo "$0" "$#" "$@"' > rc
$ (ENV=rc exec -a sh bash -s foo bar)
sh 0
sh-4.4$ exit
exit
$ bash --rcfile rc -s foo bar
bash 0
bash-4.4$ exit
$ BASH_ENV=rc bash -c : arg0 foo bar
bash 0
In some cases, one could work around it by using:
PROMPT_COMMAND='. ./rc; unset PROMPT_COMMAND' bash -s foo bar
Or pass the argument via some other mean like encoded in an
environment variable.
--
Stephane