0

My script keeps dying with the error

./script.sh: 2: set: Illegal option -o pipefail

This is how I call it

var cp = require("child_process");
cp.exec("script.sh", function(){ console.log(...arguments); });

This is the script

set -e
set -o pipefail

ls .
...

I put these lines in the script because they make it die if there is an error instead of continuing. I don't know what they mean and was hoping someone could help.

user3413723
  • 11,147
  • 6
  • 55
  • 64
  • Can you send your nodejs app (or a standalone snippet that works) for me to try it locally? – Bguess Apr 24 '22 at 03:53
  • 1
    That error message looks like it's coming from dash, which doesn't have a `pipefail` option. You need to run the script under bash or zsh. Check its shebang line. See ["Linux/Ubuntu set: Illegal option -o pipefail"](https://stackoverflow.com/questions/54055549/linux-ubuntu-set-illegal-option-o-pipefail) or possibly ["equivalent of pipefail in dash shell"](https://stackoverflow.com/questions/17757039/equivalent-of-pipefail-in-dash-shell). – Gordon Davisson Apr 24 '22 at 03:59
  • @GordonDavisson You did great! Adding a shebang fixed it! Do you want to write it as an answer so I can give you credit? – user3413723 Apr 24 '22 at 04:15
  • @user3413723 Since it's pretty close to the other question, and Mike's answer there is pretty much the solution that did it (just from a different starting point), I'll mark it as a duplicate and you should give Mike an upcode. – Gordon Davisson Apr 24 '22 at 07:54

0 Answers0