$0 shell parameter holds the name of the calling program. If you make a symbolic link named
my_command in your home directory to the command
/usr/local/bin/command1 and you execute it by typing
./my_command, what will be the value of
$0? Can anyone also explain why? Thanks!
A command line (or rather, in UNIX, an array of command line arguments), including what would become
$0, is passed to the
exec call by the calling program.
Symlink resolution, shebang processing etc. is only done after that, by the system, as part of processing the
So, whatever the calling program (the shell in your case) specified as the first item in
/.my_command in your case) becomes