<?xml version="1.0" encoding="UTF-8"?>
<essay xml:lang="en" version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:gal="http://norman.walsh.name/rdf/gallery#" xmlns:foaf="http://xmlns.com/foaf/0.1/">
<info>
    
    
    
    
    
    
    
<title>Resource forks and tar</title><biblioid class="uri">http://norman.walsh.name/2008/02/22/tar</biblioid>
<volumenum>11</volumenum>
<issuenum>24</issuenum>
<pubdate>2008-02-22T08:37:56-05:00</pubdate>
<author>
      <personname>
<firstname>Norman</firstname>
	<surname>Walsh</surname>
</personname>
    </author>
<copyright>
      <year>2008</year>
      <holder>Norman Walsh</holder>
    </copyright>
<abstract>
<para>Mac filesystems have “data forks” and “resource forks”. This is
usually a really good thing. But only usually.</para>
</abstract>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#OSX"/>
</info>

<para xml:id="p1">The use of
<wikipedia page="Resource_fork">resource forks</wikipedia> on the Mac
is really very clever. Resource forks are where the Mac stores
information about what application created the file, what icon it
should have, etc. It's technically a much better solution to the problem
than relying on the filename extension and it's almost always transparent
to the user.</para>

<para xml:id="p2">Almost.</para>

<para xml:id="p3">When you create a <command>tar</command> archive, for example:</para>

<screen>$ tar cf - `find api -type f | grep -v \\.svn` | gzip &gt; api.tar.gz</screen>

<para xml:id="p4">The odds are overwhelmingly high that you don't really want all
those resource forks manifested in the archive with magic filenames:</para>

<screen>$ tar zvtf api.tar.gz | grep Makefile
-rw-r--r-- ndw/ndw         161 2008-02-07 10:26:49 api/1.2.0/._Makefile
-rw-r--r-- ndw/ndw         251 2008-02-07 10:26:49 api/1.2.0/Makefile
-rw-r--r-- ndw/ndw         161 2008-02-09 18:28:57 api/1.2.1/._Makefile
-rw-r--r-- ndw/ndw         421 2008-02-09 18:28:57 api/1.2.1/Makefile</screen>

<para xml:id="p5">It turns out that you can tell <command>tar</command> this, but not
with a command-line option, instead with an environment variable:
<envar>COPYFILE_DISABLE</envar>. Setting that to “<literal>true</literal>”
(or perhaps any value) tells <command>tar</command> not to copy resource
forks. For added confusion, this apparently undocumented environment
variable used to be called
<envar>COPY_EXTENDED_ATTRIBUTES_DISABLE</envar> in versions of Mac OS
X prior to “Leopard”. At least that works with the
<command>tar</command> that ships with OS X:</para>

<screen>$ export COPYFILE_DISABLE=true
$ tar cf - `find api -type f | grep -v \\.svn` | gzip &gt; api.tar.gz
$ tar zvtf api.tar.gz | grep Makefile
-rw-r--r-- ndw/ndw         251 2008-02-07 10:26:49 api/1.2.0/Makefile
-rw-r--r-- ndw/ndw         421 2008-02-09 18:28:57 api/1.2.1/Makefile</screen>

<para xml:id="p6">Please pardon me while I barf on my shoes.</para>

<para xml:id="p7">I hope this essay is useful to someone. But mostly I hope
it helps me remember this little bit of magic so I don't have to go
searching all over creation next time I bang my head on this problem.</para>

</essay>

