Support OS X.

The sed on OS X is ancient and limited.  If you have git, you have
perl so this should be fine everywhere.  Haven't done perl in yonks
though so this might not be idiomatic - but it does seem to work
correctly.
Merge pull request #1 from lyda/osx

Patch to support OS X.