How to Debug Shell Scripts With set -x and ShellCheck
A complete walkthrough of the two genuinely essential shell scripting debugging tools — one that traces exactly what a script actually executes, and one that catches whole categories of bugs before the script ever runs.