You should always type check your shell scripts as well. For example, you just:
$ shelltypes script.sh
# Welcome to shelltypes v 3.23.2
# type ‘help’ if you’re stuck
>>> {1) # import POSIX;;
Importing 73 items.
>>> {2} # append loadpath “/opt/local/shelltypes/base”;;
>>> {3} # import base::YOURPROJECT;;
Importing 15 items.
>>> {4} # check “YOURSCRIPT.sh”
Parsing YOURSCRIPT.sh.
Reticulating splines.
Expanding aliases.
Analyzing free shell environment variables.
Found inconsistencies in PATH.
Warning: Low battery!!!
Warning: found free type for ‘shred’, ignoring.
Warning: use of sudo requires password under /etc/sudoers.
Warning: this utility is fake.
Error: use of cat impossible in the presence of mutt.
Found 15 errors.
Try again. Goodbye.
$
Then you can be pretty sure your script isn’t going to do unnecessary harm, and has some proper guardrails in place.