Mac filesystems have “data forks” and “resource forks”. This is usually a really good thing. But only usually.
The use of resource forks 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.
When you create a tar archive, for example:
$ tar cf - `find api -type f | grep -v \\.svn` | gzip > api.tar.gz
The odds are overwhelmingly high that you don't really want all those resource forks manifested in the archive with magic filenames:
$ 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
It turns out that you can tell tar this, but not
with a command-line option, instead with an environment variable:
COPYFILE_DISABLE. Setting that to “
(or perhaps any value) tells tar not to copy resource
forks. For added confusion, this apparently undocumented environment
variable used to be called
COPY_EXTENDED_ATTRIBUTES_DISABLE in versions of Mac OS
X prior to “Leopard”. At least that works with the
tar that ships with OS X:
$ export COPYFILE_DISABLE=true $ tar cf - `find api -type f | grep -v \\.svn` | gzip > 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
Please pardon me while I barf on my shoes.
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.