Writing smart programs using bash script is not easy, there are many issues along the way and one of them is what i'm going to describe here.
Sometimes it's require for bash scripts to know their location, for example when they are part of a package and there are other require files (on the same location) for them to run properly, and it's also not possible to change the path to where they're located simply because they also need the current directory.