Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to exit the script with status 5.
Bash Scripting
exit [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
exit 0 which means success, not a custom code.Forgetting to put a number after
exit.✗ Incorrect
Using
exit 5 ends the script with exit code 5, which can be checked by the calling process.2fill in blank
mediumComplete the code to exit with status stored in variable code.
Bash Scripting
code=7 exit [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
exit code which tries to exit with a command named 'code'.Using quotes around variable name which makes it a string, not a number.
✗ Incorrect
Use
${code} to expand the variable value for exit status.3fill in blank
hardFix the error in the script to exit with code 3 if count is less than 5.
Bash Scripting
count=3 if [ $count [1] 5 ]; then exit 3 fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
== which tests equality, not less than.Using
= which is for assignment, not comparison.✗ Incorrect
Use
-lt inside [ ] to check if count is less than 5.4fill in blank
hardFill both blanks to exit with code 2 if status equals 1.
Bash Scripting
status=1 if [ $status [1] 1 ]; then exit [2] fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
!= which means not equal.Exiting with wrong code like 1 instead of 2.
✗ Incorrect
Use
== to check equality and exit 2 to exit with code 2.5fill in blank
hardFill all three blanks to exit with code 4 if error is true and count is greater than 10.
Bash Scripting
error=true count=15 if [ $error == true ] && [ $count [1] [2] ]; then exit [3] fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
< instead of > for comparison.Exiting with wrong code like 10 or 1.
✗ Incorrect
Use
> to check if count is greater than 10, and exit 4 to exit with code 4.