Use Pathname.write_exec_script: https://github.com/mxcl/homebrew/blob/master/Library/Homebrew/extend/pathname.rb#L375