Fix bashisms in shell scripts

Bashisms in scripts may cause problems on systems where the default
shell is not Bash.

I could not test the changes on Darwin lacking the development environment.
thats invalid. use [ $RET -eq 65 ], same for next hunk.