Hi everyone,
I’ve been stuck for hours on the very first step of the “Learn Bash Scripting by Building Five Programs” course on freeCodeCamp (the CodeRoad interactive tutorial). The task is simple: in the countdown.sh script, change the if condition to check if the first argument is greater than zero using [[ $1 -gt 0 ]]. The script should then echo the argument if true, or a message if false.
What I’ve tried:
· I’ve written the script exactly as instructed:
#!/bin/bash
# Program that counts down to zero from a given argument
if [[ $1 -gt 0 ]]
then
echo $1
else
echo Include a positive integer as the first argument.
fi
· When I run bash countdown.sh 5 in the terminal, it correctly outputs 5.
· I’ve used cat -A countdown.sh to check for hidden characters – no ^M, only $ at line ends.
· I ran file countdown.sh – it says ASCII text executable.
· bash -n countdown.sh shows no syntax errors.
· I tried both [[ … ]] and [ … ] (single brackets).
· I deleted any extra backup files like countdown.sh.save.
· I used sed -i ‘s/\r$//’ countdown.sh to ensure no Windows line endings.
· I even reset the project multiple times and retyped the code manually (no copy-paste).
· I also tried the simpler version from the tutorial video (with -le 5 and echo true/false) – but that also didn’t pass.
The problem: Every time I click Run, the test fails with the message:
Your script should have the suggested “if/else” statement added correctly
(no more details). The terminal shows no errors, and the script works perfectly when executed manually.
What I see in the editor: The file content looks correct, and there are no red squiggles. But the CodeRoad test just won’t accept it.
I suspect it might be something environmental – maybe the test expects a very specific format (like no blank lines, or a particular indentation) or there’s a caching issue. I’ve tried refreshing the page and using incognito mode, but no luck.
Has anyone else encountered this? Any ideas on what might be wrong or how to debug further? I’d really appreciate any help!
Thanks in advance.
