Challenge - 5 Problems
Exit Code Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the exit code of this script?
Consider this bash script:
What will be the exit code when this script finishes?
#!/bin/bash exit 42
What will be the exit code when this script finishes?
Bash Scripting
#!/bin/bash exit 42
Attempts:
2 left
💡 Hint
The exit command returns the number you give it as the exit code.
✗ Incorrect
The script uses 'exit 42', so the exit code is 42.
💻 Command Output
intermediate1:30remaining
What is the exit code after this command?
You run this command in bash:
What will be the actual exit code returned?
exit 300
What will be the actual exit code returned?
Bash Scripting
exit 300Attempts:
2 left
💡 Hint
Exit codes are limited to 0-255 and wrap around using modulo 256.
✗ Incorrect
300 modulo 256 is 44, so the exit code is 44.
🔧 Debug
advanced2:00remaining
Why does this script always exit with code 0?
Look at this script:
Why does it always exit with code 0 even though 'false' failed?
#!/bin/bash false exit 0
Why does it always exit with code 0 even though 'false' failed?
Bash Scripting
#!/bin/bash false exit 0
Attempts:
2 left
💡 Hint
The last exit command sets the script's exit code.
✗ Incorrect
The script runs 'false' which returns 1, but then runs 'exit 0' which sets the exit code to 0.
🧠 Conceptual
advanced1:00remaining
What is the valid range for exit codes in bash?
Which of these is the correct range for exit codes in bash scripts?
Attempts:
2 left
💡 Hint
Exit codes are stored in a single byte.
✗ Incorrect
Exit codes are 8-bit unsigned integers, so valid values are 0 to 255.
🚀 Application
expert2:00remaining
What is the exit code of this script?
Consider this bash script:
What exit code will the script return when run?
#!/bin/bash if false; then exit 1 else exit 256 fi
What exit code will the script return when run?
Bash Scripting
#!/bin/bash if false; then exit 1 else exit 256 fi
Attempts:
2 left
💡 Hint
256 modulo 256 is 0.
✗ Incorrect
The 'if false' condition fails, so the else branch runs 'exit 256'. 256 modulo 256 is 0, so exit code is 0.