Port from bash to sh. Possible edge cases not tested with this script.

You (or someone) linked this git-open thing to #go-nuts @freenode and I mentioned about using sh instead of bash, and then this happened.
The ported script worked in basic cases for me, but do test it to see if does what it is supposed to do.