Q:

Problems with Bash 4.2.45 on Ubuntu

I am using a remot server running Ubuntu 13.10 with Bash 4.2.45 installed. My home system is OS X Mavericks with Bash 3.2.51 (Darwin build) installed. I haven't used bash much in the past but I've been working on a pretty big script and noticed a few things that were weird about the version installed on the remote server.
Take a simple script for example:
#!/bin/sh

read n

if ((n > 10)); then
        echo "Number is pretty big"
else
        echo "NUMBER IS WEAK AND SMALL"
fi

While under bash 3.2.51 it recognizes the expression and works under the bash 4 on Ubuntu it throws a weird error:
script.sh: 5: script.sh: n: not found

But not only are (( . . . )) not recognized but sometimes variables and other logical statements. As a bash beginner it's very confusing and I wanted to ask what I could do about that. Can I change the syntax rules? Or just downgrade the remote server to a 3.x.y version?
Any help is appreciated.

A:

When i've read your query i was surprised by the behaviour you have, so i've decided to reproduce it quickly, so i've setup a new Ubuntu 13.10 VM with Bash version 4.2.45.
Once done, i was able to reproduce the behaviour you describe.
After further investigations, it seems that you just have to replace #!/bin/sh by #!/bin/bash to make it works.
Edit :
To launch the script :

bash script.sh and ./script.sh will work.
sh script.sh will not work.

Assuming you have #!/bin/bash at first line
Hope it will work for you !

