Zeroth Argument Limitations
The inconsistency in the zeroth argument between scripts and compiled programs means that the only consistent behavior using the zeroth argument relies on:
not using the zeroth argument to convey anything other than the invoked program name or file path, and
using just the part of the zeroth argument after the last slash, discarding all the directory parts if any.
Using the zeroth argument to convey anything else to the program only works if the program is compiled. Therefore no conventions based on using the zeroth argument to convey other information are portable - not even portable within the same system, across all programs that run on that system.
For example, it can seem pretty reasonable to use the zeroth argument as a way to say
hey program, in this context, you are "named" {{ some text }}, so put that in places where it is more appropriate to use your in-context name instead of your "official" name, such as your error messages
but this inherently does not work with scripts. The closest you can come to making it work is creating a link to the script named {{ some text }} somewhere on the file system, minding all the issues like multiple concurrent invocations with the same {{ some text }}, possibly of different programs, by different users with different permissions, and the need to clean up the links.
And making the difference between the presence of absence of directory parts significant to your functionality marries what should be an internal implementation choice - compiled or scripted - to your public interface.














