pact-foundation / pact-ruby-standalone

A standalone pact command line executable using the ruby pact implementation and Travelling Ruby
https://pact.io
MIT License
42 stars 33 forks source link

Explicitly use bash for packaging shell scripts #51

Closed joshdick closed 4 years ago

joshdick commented 4 years ago

pact-ruby-standalone appears to be used by the @pact-foundation/pact NPM package.

On macOS Catalina, /bin/sh defaults to zsh when it previously used to default to bash in earlier versions of macOS.

This change breaks the following line that appears in many of the packaging scripts, which does not work properly in zsh:

DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

Since I imagine most consumers of this package will have bash installed, I updated the shebang in all of the packaging scripts to explicitly use the default version of bash via /usr/bin/env, rather than using the more general /bin/sh, which may not actually be bash.

joshdick commented 4 years ago

Possibly related to #48.

bethesque commented 4 years ago

@mefellows did we end up just saying that people had to have bash installed for all those alpine docker issues?

mefellows commented 4 years ago

So this is at least more explicit, and so it's likely better because it should at least fail if bash isn't present with a clearer error.

Ideally, we drop down a level and make it work across all common shells (e.g. Ubuntu defaults to dash or ash, can't remember, Mac is now zsh etc.). And then we wouldn't need to worry so much.

And yes, our docs explicitly state that bash is required for it to run. It just won't work on Alpine without it.

bethesque commented 4 years ago

I had a look at doing cross shell compatible code, and it looks like it's far too complicated to be worth it, given we want to retire this package anyway. https://stackoverflow.com/questions/29832037/how-to-get-script-directory-in-posix-sh