I am having troubles understanding variables {_,0} in the following example.
In script tmp.sh
:
func()
{
echo $_
echo $0
echo $1
}
calling tmp.sh with parameter x:
~$ ./tmp.sh x
./tmp.sh
./tmp.sh
x
and sourced tmp.sh with parameter x:
~$ . ./tmp.sh x
x
bash
x
As I understand $_
and $0
, the later is for the first argument as in first example it's ./tmp.sh
. Why it's equivalent to bash in the second example?
What does .
expand to, and the former, which I am not sure about, return last parameter with sourced bash, and equivalent to $0 in unsourced bash. Is that the case?