Can anybody explain to me what the shell does in the two examples A) and B) below? It obviously behaves differently, but I can't find out why the output is different.
Example:
Let's have a script in our current directory named bla.sh
with only one command:
echo ${0##/*} hello
A)
Started as: ./bla.sh
gives: ./bla.sh hello
B)
Started as: . bla.sh
gives: -bash hello
Since I use this in a script, the second output (because of the "-" in front of the -bash) kills the command. Of course, a simple --
before the ${...}
helped, but I would love to understand what causes the output in the first place.
I love bash. And vi[m]. But I digress…