Editing my own .sh file with TextEdit sets the quarantine bit, why?

I've just bought a new MacBook Pro M1, and restored everything from my old Intel MacBook Pro using a Time Machine backup.

It was a pretty smooth process, a few glitches such as needing to re-download certain apps to get the M1 version (e.g. Android Studio).

One thing that I've noticed, and I don't know whether this is a Monterey thing or an M1 thing but as part of my day-to-day development work, I maintain various .sh files for building projects on different platforms.

I have found that as soon as I edit and save an existing .sh file using TextEdit, it then sets the quarantine bit on the file and prevents it running from inside Zsh:

zsh: operation not permitted: ./test.sh

xattr yields the following:

xattr ./test.sh 

com.apple.TextEncoding com.apple.lastuseddate#PS com.apple.macl com.apple.metadata:kMDLabel_pjtfm5adga5rvjv2xmgkyqjwmq com.apple.quarantine

This is incredibly annoying and I can't believe it is by design - this is not a file that has been downloaded from the Internet, it's my own file. Why can't I edit it using TextEdit?

I do not get the same problem when I edit and save using Sublime Text, as one example, so what's with TextEdit doing that?

TextEdit is a sandboxed app and, as such, can’t create an executable without it being quarantined. I’m surprised that you didn’t see this problem on earlier systems. Certainly, I’ve seen it with other sandboxed text editors, most notably BBEdit. However, I tested this for myself and I see the same change in behaviour between 11.6 and 12.0.

Regardless, if you find the new behaviour annoying you should definitely file a bug about it. It may comes back as ‘behaves correctly’, but at least that way you’ll know for sure.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks, yes I've never seen it before with any text editor, it's the first time I've encountered it after upgrading to Monterey and only with TextEdit.

I'll certainly file a bug report as it basically means I cannot easily use TextEdit to edit my own sh files, which surely cannot be the intention.

I just encountered the exact same issue here in Monterey 12.1 on a Mac Mini M1 (2020).

This is pretty annoying and also for me unexpected behaviour, especially if that script file was created by yourself on your own computer and had been executing just fine before editing it with TextEdit...

I filed a bug report in the Feedback Assistant: bug number FB9815707.

I'm experiencing this right now. Combination of TextEdit and Monterey on a "new" MacBook. Maybe I didn't notice it in the old MacBook because I wasn't editing the .sh file.

Editing my own .sh file with TextEdit sets the quarantine bit, why?
 
 
Q