Challenge - 5 Problems
ShellCheck Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What does ShellCheck report for this script?
Given the following Bash script, what warning or error will ShellCheck produce?
Bash Scripting
echo "User input is: $1" if [ $1 -eq 10 ]; then echo "Input is ten" fi
Attempts:
2 left
💡 Hint
ShellCheck often warns about unquoted variables in test conditions.
✗ Incorrect
ShellCheck warns that $1 should be quoted in the test to avoid word splitting or globbing issues.
📝 Syntax
intermediate2:00remaining
Which script will pass ShellCheck without errors?
Select the Bash script snippet that will NOT produce any ShellCheck warnings or errors.
Attempts:
2 left
💡 Hint
ShellCheck warns about unquoted variables that may cause word splitting.
✗ Incorrect
Option B quotes the variable properly, avoiding word splitting and globbing issues.
🔧 Debug
advanced2:00remaining
Identify the ShellCheck warning for this script
What specific ShellCheck warning will this script produce?
Bash Scripting
#!/bin/bash read -p "Enter your name: " name if [ "$name" = "" ]; then echo "No name entered" fi
Attempts:
2 left
💡 Hint
ShellCheck warns about read command usage without -r option.
✗ Incorrect
ShellCheck recommends using read -r to prevent backslash escapes from being interpreted.
🧠 Conceptual
advanced2:00remaining
Why does ShellCheck warn about this variable usage?
Consider this snippet:
filename=$1
if [ -f $filename ]; then
echo "File exists"
fi
Why does ShellCheck warn about the test condition?
Attempts:
2 left
💡 Hint
Think about what happens if the filename contains spaces.
✗ Incorrect
ShellCheck warns that unquoted variables in tests can cause unexpected behavior if the variable contains spaces or special characters.
🚀 Application
expert2:00remaining
What is the output of running ShellCheck on this script?
Given this script:
#!/bin/bash
for i in {1..3}
do
echo "Number: $i"
done
What output will ShellCheck produce?
Attempts:
2 left
💡 Hint
Brace expansion is valid in Bash and commonly used in loops.
✗ Incorrect
The script uses valid brace expansion and quotes the variable properly, so ShellCheck reports no issues.