Semi-OT: Why Kids Can't use Computers

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Fri Aug 16 21:02:47 UTC 2013


On Thu, Aug 15, 2013 at 06:50:14PM -0400, Kevin Cozens wrote:
> On 13-08-15 03:32 PM, Walter Dnes wrote:
> > #!/bin/bash
> > for counter in {1..100}
> > do
> >    if [ $(( ${counter} % 15 )) -eq 0 ]; then echo  "Fizz-Buzz"
> >    elif [ $(( ${counter} % 3 )) -eq 0 ]; then echo  "Fizz"
> >    elif [ $(( ${counter} % 5 )) -eq 0 ]; then echo  "Buzz"
> >    else echo ${counter}
> >    fi
> > done
> 
> Do you lose points for typos? (Fizz-Buzz instead of FizzBuzz)  :)
> 
> Under Linux Mint 14 which uses dash (instead of bash) as default kernel, the
> example program doesn't run.
> 
> sh fizzbuzz.sh
> fizzbuzz.sh: 4: fizzbuzz.sh: arithmetic expression: expecting primary: "
> {1..100} % 15 "

That is a user error.  The #! line explicitly said /bin/bash, so you
screwed up by using sh.

If you had done chmod a+x on it, and then run it, it would have worked
fine, no matter what sh is.

-- 
len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list