Recall & Review
beginner
Why should you use comments in bash scripts?
Comments explain what the script or parts of it do. They help others and your future self understand the code easily.
Click to reveal answer
beginner
What is the recommended way to name variables in bash scripts?
Use uppercase letters with underscores, like MY_VARIABLE. This makes variables easy to spot and avoids conflicts with system variables.
Click to reveal answer
intermediate
Why should you use double quotes around variables in bash scripts?
Double quotes prevent word splitting and globbing, which can cause unexpected behavior when variables contain spaces or special characters.
Click to reveal answer
intermediate
What is the purpose of using 'set -e' at the start of a bash script?
'set -e' makes the script stop immediately if any command fails. This helps catch errors early and avoid running wrong commands.
Click to reveal answer
beginner
How should you format your bash script for readability?
Use indentation for blocks like loops and conditionals, add blank lines between sections, and keep lines short. This makes the script easier to read and maintain.
Click to reveal answer
What is the best way to name variables in bash scripts?
✗ Incorrect
Uppercase letters with underscores are the standard for bash variables to improve readability and avoid conflicts.
Why should you put double quotes around variables in bash scripts?
✗ Incorrect
Double quotes protect variables from splitting into multiple words or matching filenames unexpectedly.
What does 'set -e' do in a bash script?
✗ Incorrect
'set -e' makes the script exit immediately on any error, helping catch problems early.
Which of these is a good practice for bash script readability?
✗ Incorrect
Indentation and blank lines make scripts easier to read and understand.
Why add comments in your bash scripts?
✗ Incorrect
Comments help others and yourself understand the purpose and function of the code.
Explain three key style guide rules you should follow when writing bash scripts.
Think about naming, quoting, and documentation.
You got /3 concepts.
Describe how formatting and error handling improve bash script quality.
Consider readability and safety.
You got /3 concepts.