Un-quarantine downloaded files on OS X
Though I agree in principle with the idea of marking downloaded files as hazardous, it can be quite annoying when, say, extracting piles and piles of W3C documentation for future reference — especially when opening some index.html pops up a dialog box about a downloaded application. The “downloaded application” marker OS X puts on downloaded files is in fact an extended attribute.
The attribute in question is “com.apple.quarantine”, as shown below:
$ ls -l@ total 1560 drwxr-xr-x 25 mzwier staff 850 Jul 22 18:04 html40 -rw-r--r--@ 1 mzwier staff 369830 Jul 22 18:00 html40.tgz com.apple.quarantine 42
The tool to manage extended attribute data is (logically), “xattr”. xattr has no man page, but an informative-enough help option (this directly from xattr --help, reprinted for reference and discussion):
$ xattr --help
usage: xattr [-l] file [file ...]
xattr -p [-l] attr_name file [file ...]
xattr -w attr_name attr_value file [file ...]
xattr -d attr_name file [file ...]
The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to attr_value.
The fourth form (-d) deletes the xattr attr_name.
options:
-h: print this help
-l: print long format (attr_name: attr_value)
So, to lift the quarantine on a specific file, the proper move is
xattr -d com.apple.quarantine FILE
To lift the quarantine on a whole directory tree (say, of documentation), the move is
find DIRNAME -print0 | xargs -0 xattr -d com.apple.quarantine
Tags: OS X
You can comment below, or link to this permanent URL from your own site.