I've been trying to run on Ubuntu 16 a bash script that I developed on CentOS 7.
The first line of the script is:
set -o nounset -o pipefail -o errexit
When I try to run this script, I get the following error:
project.sh: 6: set: Illegal option -o pipefail
How to solve this issue?
I also the solution explain in the answer to this question but it did not help (my file is not a make
).
#!/bin/sh
?bash scriptname
, it the first line#! /bin/bash
?#!/bin/sh
, but I was invoking it assh project.sh
as in CentOS! Now I tried to runbash project.sh
and the problem disappeared! Thanks guys!sh
is symlink todash
shell on Ubuntu. Also, start changing your habits. Usechmod +x script.sh
and./script.sh
to run it. The way you do itsh ./script.sh
has whole lot of issues of its own and easy to mess upbash project.sh
fixed your error, then you should change your shebang line to#!/bin/bash
that way you don't have to type in thebash
in front of your script name.