add support for osx, avoid setting global variables

This adds support for the darwin "open" command which works equivalently to the other two.  I also changed the platform indicator variables to be local to the script, since they probably aren't meant to be exported.