Invalid option name error with shebang "#!/bin/bash -o pipefail" in script
5,045
The Linux kernel treats everything following the first “word” in the shebang line as a single argument. One solution is to set -o
later in the script:
#!/bin/bash
set -o pipefail
echo "Running test"
git diff HEAD^ HEAD -M --summary | grep delete | cut --delimiter=' ' -f 5
Author by
firedrillsergeant
Updated on September 18, 2022Comments
-
firedrillsergeant over 1 year
I have a file named test.sh:
#!/bin/bash -o pipefail echo "Running test" git diff HEAD^ HEAD -M --summary | grep delete | cut --delimiter=' ' -f 5
When I try to run this script as:
./test.sh
I get:
/bin/bash: line 0: /bin/bash: ./test: invalid option name
I ran
cat -v test.sh
to check if there are carriage returns or anything, but that doesn't seem to be the case. I can run the script if I just run it asbash test.sh
. Grateful for any help, and lmk if I can provide more info!-
Angel Todorov almost 5 yearsIf this is linux, check your execve man page.
-