$0 expands to the name of the shell script.
$ cat ./sample-script
#!/bin/bash
echo $0
$ chmod 700 ./sample-script
$ ./sample-script
./sample-script
If the shell script is invoked via a symbolic link, $0 expands to its name:
$ ln -s ./sample-script symlinked-script
$ ./symlinked-script
./symlinked-script
How could I get the name of an alias? Here `$0′ expands again to the filename:
$ alias aliased-script=./sample-script
$ aliased-script
./sample-script
I imagine you already know this, but for the record the answer is: you need cooperation by the code implementing the alias.
or, if you really want to use the superseded alias syntax:
…and then…