cd "$(dirname "$0")"
Add this to the top of your script to have it cd
to the directory the script is installed at. Then you can use relative paths and they'll be relative to the script dir and not the user's pwd
.
If for whatever reason dirname
isn't available, here's an equivalent statement that uses basename
instead.
cd "${0%%/$(basename "$0")}"