News for hackers. Stuff that matters.
Re:Unix Shell Programming: The Next 50 Years [pdf] by enriquto on Friday June 04, 2021 @11:57AM (#27394922)
I agree that it may be possible to implement this feature in a nice form where it makes sense (for the people who need it). But it seems really strange to me and I cannot imagine a use for it. Conceptually, the shell only sees the contents of the script, why would it act differently according to where the script is? When you open a jpeg image, the jpeg library does not provide a facility to recover the directory where that file was found. For all you know, this may be an in-memory jpeg. Isn't the same with shell scripts?
Re:Unix Shell Programming: The Next 50 Years [pdf] by coldtea on Friday June 04, 2021 @12:46PM (#27395555)
>Conceptually, the shell only sees the contents of the script, why would it act differently according to where the script is?

Doesn't need to act differently in what it does.

But it does need to report it, because e.g. you might want to bundle data/assets/config relative to the script, and want to be able to run it from wharever and have it still be able to find it.

Re:Unix Shell Programming: The Next 50 Years [pdf] by WildcardWiz on Friday June 04, 2021 @01:22PM (#27396106)
It's an interesting question. In most shell, it is possible to "source" a given file, which basically is a form of file inclusion. How should the script location feature behave in that situation? Should it report the sourced file location, or the sourcing one?

In the later case, does it mean that it is not possible to write reusable code based on that feature? In the former case, what should be done when sourcing is done recursively? Can this be used to defeat file location, for instance, by generating a script in /tmp and sourcing another file from it?

Re:Unix Shell Programming: The Next 50 Years [pdf] by oblio on Friday June 04, 2021 @03:38PM (#27398166)
First of all: https://en.wikipedia.org/wiki/Argument_from_incredulity

Secondly, it's super frequent that scripts I write or that others write need the folder they're executed in as an argument.

99% of scripts I've seen aren't meant to be piped to. They're just launched as simple, dumb, standalone "programs".