0
0
Linux CLIscripting~10 mins

Shell options (set -e, set -x) in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to make the shell script stop on any error.

Linux CLI
set [1]
Drag options to blanks, or click blank then click option'
A-v
B-x
C-e
D-n
Attempts:
3 left
💡 Hint
Common Mistakes
Using -x instead of -e, which only shows commands but doesn't stop on error.
Using -v or -n which do not stop the script on errors.
2fill in blank
medium

Complete the code to print each command before executing it.

Linux CLI
set [1]
Drag options to blanks, or click blank then click option'
A-x
B-e
C-v
D-u
Attempts:
3 left
💡 Hint
Common Mistakes
Using -e which stops on errors but does not print commands.
Using -v which prints input lines but not expanded commands.
3fill in blank
hard

Fix the error in the script to stop on errors and print commands.

Linux CLI
set [1] [2]
Drag options to blanks, or click blank then click option'
A-x
B-e
C-v
D-n
Attempts:
3 left
💡 Hint
Common Mistakes
Using only one option and missing the other.
Using -v which prints input lines but not commands.
4fill in blank
hard

Fill both blanks to create a script that stops on errors and prints each command before executing it.

Linux CLI
#!/bin/bash
set [1] [2]
echo "Start script"
false
echo "This will not run"
Drag options to blanks, or click blank then click option'
A-e
B-x
C-v
D-n
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v or -n which do not stop on errors or print commands as needed.
Reversing the order of options does not matter but missing one option breaks behavior.
5fill in blank
hard

Fill all three blanks to create a script that stops on errors, prints commands, and treats unset variables as errors.

Linux CLI
#!/bin/bash
set [1] [2] [3]
echo "Running script"
echo "$UNSET_VAR"
Drag options to blanks, or click blank then click option'
A-e
B-x
C-u
D-v
Attempts:
3 left
💡 Hint
Common Mistakes
Missing the -u option so unset variables do not cause errors.
Using -v which prints input lines but is not needed here.