use functions instead of variables for os detection

Shell functions are easier to use in if statements than variables.
The code also relies no on OSTYPE instead of uname which is a little bit faster.
If you insist on using variables I would at least use OSTYPE instead of uname.