0

This question already has an answer here:

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 as bash test.sh. Grateful for any help, and lmk if I can provide more info!

marked as duplicate by Kusalananda bash Aug 1 at 17:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You can pass a single argument in the shebang, and you're trying to pass it two (-o and pipefail). I don't know of any system where that (still) works. – Uncle Billy Aug 1 at 17:45
  • If this is linux, check your execve man page. – glenn jackman Aug 1 at 17:47
1

Try to use set, like this :

#!/bin/bash

set -o pipefail

echo "Running test"
git diff HEAD^ HEAD -M --summary | grep delete | cut --delimiter=' ' -f 5

Not the answer you're looking for? Browse other questions tagged or ask your own question.