Debugging scripts
Appearance
General
- You can invoke the shell with cli options or you can use set options in the shell for debugging
- the set options look lame, here are the cli options
- sh -n <script name>
- checks for syntax errors only, does not execute the commands in the script
- sh -v <script name>
- echoes commands before running them
- sh -x <script name>
- echoes commands after processing on the cli
- you can find the program state wherever it exits by trapping the EXIT signal. Place this line at the start of the script
- trap 'echo Exiting: critical variable = $critical_variable' EXIT