De seção especial do man page do bash :
0 Expands to the name of the shell or shell script. This is set at shell initialization. If bash is invoked with a file of commands, $0 is set to the
name of that file. If bash is started with the -c option, then $0 is set to the first argument after the string to be executed, if one is present.
Otherwise, it is set to the filename used to invoke bash, as given by argument zero.
Basicamente, $0
fornecerá o nome do script ao executar um script ou bash se o modo interativo. Observe que .
, que é um alias para source
, não é um executável, mas um shell integrado, portanto, não altera o valor de $ 0 e mantém o bash no modo interativo.
_ At shell startup, set to the absolute pathname used to invoke the shell or shell script being executed as passed in the environment or argument list.
Subsequently, expands to the last argument to the previous command, after expansion. Also set to the full pathname used to invoke each command exe‐
cuted and placed in the environment exported to that command. When checking mail, this parameter holds the name of the mail file currently being
checked.