Unix Commands  «Prev  Next»
Lesson 9

Debug shell scripts Conclusion

In this module, you learned some techniques to debug shell scripts. You also looked at some commonly found errors.

Key commands

This module introduced you to the following commands:
  1. sh v
  2. sh x
  3. trap

In this module, you learned how to:
  1. Use shell options to test each line of a script
  2. Identify syntax errors and logic errors
  3. Insert shell commands to list the progress of a script
  4. Run a shell script with tracing options
  5. Use the trap command to handle signals sent to a shell script

This module introduced you to the following terms:

Glossary terms

  1. trace/tracing: Shell tracing simply means tracing the execution of the commands in a shell script. To switch on shell tracing, use the
    -x debugging option.
    
  2. nested loop
  3. trap: Trap allows you to catch signals and execute code when they occur. Signals are asynchronous notifications that are sent to your script when certain events occur.
  4. signal: You can list down all the signals supported by your system. Just issue the kill -l command to display all the supported signals.
  5. syntax error: A syntax error is an error in the source code of a program. Since computer programs must follow strict syntax to compile correctly, any aspects of the code that do not conform to the syntax of the programming language will produce a syntax error.
  6. logic error: A logic error (or logical error) is a mistake in a program's source code that results in incorrect or unexpected behavior.
The next module is about collecting script commands into logical groupings called functions.

debugging Shell Scripts - Quiz

Click the Quiz link below to test your knowledge of debugging shell scripts.
Debugging Shell Scripts - Quiz