Going to use this opportunity to spam ShellCheck, because it has historically saved me dozens of hours catching many silent Bash scripting errors and just making my scripts more robust/warning me of obscure edge cases:

https://www.shellcheck.net/

shellcheck is so good it's even worth installing the 100+ required haskell libraries

I've always just run it as a docker command. Here's what's listed on the github page [1]:

    docker run --rm -v "$PWD:/mnt" koalaman/shellcheck:stable myscript

[1] https://github.com/koalaman/shellcheck