At the beginning of each file:
#!/bin/bash
set -euf -o pipefail
cd $(dirname $0)
Then add "" everywhere ;) And they say, write Python instead, except I’m dubious because python programs can have a lot of dependencies which can be tricky to install.