Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
12 views5 pages

Debugging A Bash Shell Script

The document discusses debugging Bash shell scripts, focusing on identifying the causes of script failures due to syntax and runtime errors. It highlights the use of the 'set' command with various options for debugging, such as syntax checking and command execution tracing. The document emphasizes that Bash acts as an interpreter, executing scripts line by line and potentially throwing errors during execution.

Uploaded by

varun186
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Debugging A Bash Shell Script

The document discusses debugging Bash shell scripts, focusing on identifying the causes of script failures due to syntax and runtime errors. It highlights the use of the 'set' command with various options for debugging, such as syntax checking and command execution tracing. The document emphasizes that Bash acts as an interpreter, executing scripts line by line and potentially throwing errors during execution.

Uploaded by

varun186
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Debugging Bash Shell Scripts

NarendraP

Learn How to Automate Common Tasks with Bash Shell Scripting


Debugging Bash Shell Scripts
 Debugging is determining the cause which fails the script.
 Why script fails ?
 Because of some errors.
 This is because of two type of errors.
 Syntax Errors
 Runtime Errors
 Syntax Errors stops script execution and run time errors don’t stop script.
 Actually we don’t have good debugging procedures with shell scripting, but we can try with some
commands.
 And there are different commands for debugging and we will work with set command.

 One more thing our bash is an interpreter.

Learn How to Automate Common Tasks with Bash Shell Scripting


Debugging Bash Scripts…
 We can go with set command and We have different options with set command.
 Syntax:
 set [options]
 No Options: To list system defined variables
 set -n No Execution, Purely for syntax check.
 set -x Prints the command before executing it in script
 set -e Exit Script if any command fails

Learn How to Automate Common Tasks with Bash Shell Scripting


Thank you
Debugging Bash Scripts
 We are working with shell scripting and we are using bash as our shell, means OS is executing our
shell scripts using bash shell.
 Now here, important point is bash is an interpreter.
 Interpreter is a kind of a program, which is used to execute code/script.
 How Interpreter(Bash) executes script(s) ?
 It reads and executes our code/script line by line.
 Sometimes it throws an exception/error while executing code/script.
 This is because of two type of errors.
 Syntax Errors
 Runtime Errors
 Syntax Errors stops our script execution and run time errors don’t stop our script.
 Here: Debugging is simply, determining the cause which fails the script.
 Actually we don’t have good debugging procedures with shell scripting, but we can try with some
commands.
 And there are different commands for debugging.

Learn How to Automate Common Tasks with Bash Shell Scripting

You might also like