News for hackers. Stuff that matters.
Re:Unix Shell Programming: The Next 50 Years [pdf] by gnubison on Saturday June 05, 2021 @11:47PM (#27410616)
> How do you find where the script itself is?

No program can do this portably.

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.

Re:Unix Shell Programming: The Next 50 Years [pdf] by gnubison on Sunday June 06, 2021 @12:49PM (#27414381)
You're right, my bad.