make the script work on OS X
fixes #687
Merge pull request #756 from vladak/osx

make the script work on OS X