OK, I'm having a similar problem to: -bash: Applications/mvim: /bin/sh: bad interpreter: Operation not permitted - but it's not the same problem. I'm getting the same result.
I've already verified that it's not the com.apple.quarantine flag.
It's not the line endings (script was created just from vi). I can execute the script by using:
Here's the results:
fawkes:tmp kylar$ vi simpleshell.sh fawkes:tmp kylar$ chmod +x simpleshell.sh fawkes:tmp kylar$ ./simpleshell.sh -bash: ./simpleshell.sh: /bin/bash: bad interpreter: Operation not permitted fawkes:tmp kylar$ cat simpleshell.sh #!/bin/bash export FOO=Hey echo $FOO fawkes:tmp kylar$ which bash /bin/bash fawkes:tmp kylar$ bash simpleshell.sh Hey fawkes:tmp kylar$ xattr -l simpleshell.sh fawkes:tmp kylar$
UPDATE: I don't believe it's the filesystem being mounted as noexec. I've tried running the script in 3 different places: /tmp, ~, and /source.
UPDATE2: Ok, after more digging - I created the script inside /source, which is a mounted dmg. That's where I ran xattr -l and found nothing. When I cp'd the script to ~ and ran xattr -l, it then had the com.apple.quarantine xattr. On a hunch, I looked at the mount attributes for /source and found:
/dev/disk1s9 on /Volumes/code (hfs, local, nodev, nosuid, journaled, noowners, quarantine, mounted by kylar)
So when I mount this dmg it's getting set as quarantine. How can I tell mount not to mount it with the quarantine flag? Once I removed the flag in ~, the script ran fine.