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:
docker run --rm -v "$PWD:/mnt" koalaman/shellcheck:stable myscript
[1] https://github.com/koalaman/shellcheck