4 ms·
> This line does its best to define the script’s location directory, ~~and then we cd to it. Why?~~ (struck through in original) I've done this to make little
by ben509 6y ago
> This line does its best to define the script’s location directory, ~~and then we cd to it. Why?~~ (struck through in original)
I've done this to make little bash utilities, and while it's cool when it works, it really doesn't work.
Never try to guess the script's location. You're adding very weird, broken, magical behavior with no way to test it. So keep it simple and write these scripts to expect help from the user.
If you need resources for a bash script, expect them to be in the working directory, or a standard directory, or have the user pass paths in through environment variables or other means.
Yes, it's gross and inelegant. It also won't break mysteriously.