News for hackers. Stuff that matters.
Re:FizzBuzz in ten languages by gshubert17 on Monday December 31, 2018 @11:09PM (#18798875)
Bash exit code 0 is truthy, but that's not how the if statement works:

if ((0)); then echo 0=true; else echo 0=false; fi

if ((1)); then echo 1=true; else echo 1=false; fi

# output

0=false

1=true

To work as expected, the if statements should be rewritten as

if ((i % 3 == 0 && i % 5 == 0)); then echo FizzBuzz

and so on.

There are no comments on this comment yet.