Standard Shell Exceptions

Pathname of $0

When the shell searches for a command name in the PATH and finds a shell script, POSIX specifies that it shall pass the command name as argv[0] and in the child shell script, $0 shall be set from argv[0] (POSIX Standard, section 3.9.1.1, line 779-784).

However, for an LSB shell, the system may implement either this behavior or $0 may be set to an absolute pathname of the shell script. [1]

Sourcing non-executable files

Notes

[1]

For example, bash behaves in the following way:
$ cat ~/prefix/bin/mycommand
#!/bin/sh
echo $0
$ PATH=~/prefix/bin mycommand
/home/kingdon/prefix/bin/mycommand
$ 
With a POSIX shell, the output would be "mycommand".

When bash is executing an executable rather than a shell script, it seems to behave in the POSIX way.