Macos – Shell script – bad interpreter: Operation not permitted

macosscript

I put the below script in a file called "volume", and put that file in a folder within $PATH.
I can execute it fine by "bash thatpath/volume 10" but when I try to execute it using just "volume 10" from anywhere I get "/bin/bash: bad interpreter: Operation not permitted". The file's permissions are 755.

#!/bin/sh

FIRST_ARGUMENT="$1"
echo "Set volume to $FIRST_ARGUMENT!"
osascript -e "set volume output volume $FIRST_ARGUMENT"

Best Answer

I read some similar issue and they also noted that the line endings might be messed up. So I started a new file and typed that all once more and saved. +x:ed it and it started working. So I guess yes, the line endings were the culprit. I did edit the file first time with TextEdit, it shouldn't give Windows line endings but um anyway it's fixed now.

Related Question