Solve issue with realpath on Mac OS X.

* realpath doesn't work on Mac OS systems. I found the following workaround that should work in any distro. More info [here](http://serverfault.com/questions/40144/how-can-i-retrieve-the-absolute-filename-in-a-shell-script-on-mac-os-x)