Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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
fawkes:tmp kylar$ chmod +x 
fawkes:tmp kylar$ ./ 
-bash: ./ /bin/bash: bad interpreter: Operation not permitted
fawkes:tmp kylar$ cat 
export FOO=Hey
echo $FOO
fawkes:tmp kylar$ which bash
fawkes:tmp kylar$ bash 
fawkes:tmp kylar$ xattr -l 
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 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.

share|improve this question
If you don't get your answer here, consider asking on UNIX and Linux SE. – Max Ried Sep 19 '12 at 16:00
I may just cross-post it anyways - this is basically blocking me from getting any work done :( – Kylar Sep 19 '12 at 16:01
Are you able to run other programs on the same filesystem in a similar fashion? That is using chmod +x; ./ Maybe that filesystem's mounted with the "noexec" flag. – cm2 Sep 19 '12 at 16:24
It might be helpful to rewrite your question to only ask about how to tell mount to not use the quarantine flag, since you now determined that was your actual problem. Also, I don't know how to disable it for a particular volume, but to disable quarantine altogether, defaults write LSQuarantine -bool NO. – houbysoft Sep 19 '12 at 16:47
OK, I have solved it. There was a xattr set on the .dmg file. I had to unmount it, clear the xattr and then remount the dmg. GAH. @houbysoft: thanks for the tip on turning it off entirely. – Kylar Sep 19 '12 at 16:50
up vote 1 down vote accepted

The script was being run from inside a .dmg that had the quarantine flag set on it. When the .dmg was mounted, it was mounting it with a quarantine flag that is inherited, but doesn't show up. I unmounted the .dmg, removed the quarantine flag, and re-mounted it, and all was well.

share|improve this answer
Thank you for this. I had a similar problem, and it was driving me crazy: A Perl script, created by Vim (or even cat), with no quarantine xattr associated with it. However, the script resided in a mounted sparse bundle. After reading this page, I unmounted the filesystem and looked inside the bundle: There was a file named "token" in there that had the "" xattr set. Once I deleted the xattr and remounted the sparse bundle filesystem, my "bad interpreter" problem with the Perl script went away. – Lee Johnson Feb 11 '14 at 17:00

I have a simple solution: cat > then run

Turns out to be an editor problem:

share|improve this answer
No, it's not a solution for my situation. As the question reads, I was using vi to create the scripts. That's an interesting link though. – Kylar Jul 11 '13 at 4:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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