Re:Unix Shell Programming: The Next 50 Years [pdf]
by chubot on Sunday June 06, 2021 @12:06AM
(#27410719)
I think you might be mixing two things up: it's impossible for a native program to find where it is, because argv[0] can be anything.
But it's possible for an interpreter to tell the script it's interpreting where it lives, i.e. argv[1]. For example, Python does this in a pretty straightforward way.
No program can do this portably.