shellcheck - static analysis tool for shell scripts
shellcheck [-s bash] FILE...
Options you will use
-s, --shell SHELL- Check as this shell: sh, bash, dash, ksh.
Gotchas
- Common codes: SC2148 missing shebang, SC2086 unquoted variable, SC2046 unquoted $( ), SC2006 backticks, SC2155
local x=$(cmd)masks the exit code, SC2164 cd without || exit, SC2162 read without -r, SC2002 useless cat. - Not installed by default: sudo apt install shellcheck.
Try shellcheck in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.