# BBEdit and Quarantine

John Simpson `<jms1@jms1.net>` 2019-06-15, last updated 2019-07-28

## The Problem

Under macOS 10.14, any files saved by BBEdit are being "quarantined" by the OS.

```
$ xattr -l ~/bin/backup-music
com.apple.FinderInfo:
00000000  54 45 58 54 52 2A 63 68 00 00 00 00 00 00 00 00  |TEXTR*ch........|
00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000020
com.apple.TextEncoding: UTF-8;134217984
com.apple.quarantine: 0086;5d056b1d;BBEdit;
```

When the `com.apple.quarantine` attribute is present, the kernel prevents the script from running.

```
$ backup-music
-bash: /Users/jms1/bin/backup-music: /bin/bash: bad interpreter: Operation not permitted
```

The attribute can be removed...

```
$ xattr -d com.apple.quarantine ~/bin/backup-music
```

... but the next time BBEdit saves the file, the attribute comes back, and the system refuses to execute the script again.

## FIX: BBEdit Sandbox Access

In BBEdit, go to Preferences -> Application. At the bottom of the right panel should be a "Sandbox access" section. If this doesn't say "allowed", click the button to allow it.

## Another option: Disable Quarantine

[This page](https://www.cnet.com/news/workarounds-for-quarantine-bug-in-os-x-lion/) explains how to disable this behaviour. However, it changes a system-wide setting which is legitimately needed for security, so BE CAREFUL with this.

```
$ defaults write com.apple.LaunchServices LSQuarantine -bool NO
```

Reboot the system after doing this.
