I tried to run a shell script and got this error:
set: Illegal option -o pipefail
I had a quick look and the first line was
-o pipefail isn't valid across POSIX shells so I would expect that to fail.
More specifically on modern Ubuntu
dash which doesn't support these
bash like constructions.
/bin/sh is very different on different systems; on some it is
bash, on others it's
ash (from which
dash is derived), and on others it's
ksh or something else.
The script probably worked on whatever system it was developed on because it had a different
This has been a problem since Ubuntu switched from
dash in 2006; a lot of scripts assumed they could use
bash and worked fine, but suddenly stopped working.
People tend to work with an implementation over a specification; if it runs on their machine it's right.
It's easy to fix by changing the shebang, for example to
#/bin/bash, or the harder way is to make the script POSIX compliant.
The excellent shellcheck will tell you what parts are not POSIX and makes it easier to chagne.