[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"$@" not available in rcfile, $ENV, $BASH_ENV...

From: Stephane Chazelas
Subject: "$@" not available in rcfile, $ENV, $BASH_ENV...
Date: Sun, 10 Sep 2017 16:11:22 +0100
User-agent: Mutt/1.5.24 (2015-08-30)

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

Reproduce it with:

$ echo 'echo "$0" "$#" "$@"' > rc
$ (ENV=rc exec -a sh bash -s foo bar)
sh 0
sh-4.4$ 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]