There are some undocumented(?) environment variables that can be used to disable the special handling of extended attributes and/or resource forks in tar (and pax, for what it is worth). rsync has the -E
/--extended-attributes
option to enable(!) this handling—but on some non-Apple rsyncs -E
means --executability
instead.
On Mac OS X 10.4 (the first release that created these AppleDouble-encoded ._*
archive members), the environment variable is COPY_EXTENDED_ATTRIBUTES_DISABLE
. In Leopard and Snow Leopard, the variable is COPYFILE_DISABLE
. Typically the variables just have to be set. Any value will do (even the empty string), but true
seems to be traditional. Thus:
COPY_EXTENDED_ATTRIBUTES_DISABLE=true COPYFILE_DISABLE=true tar …
Setting this variable has the following effects:
- When creating/updating archives:
- Prevents the creation of
._*
archive members when archiving files with extended attributes.
- Allows the creation of
._*
archive members when archiving actual ._*
files.
- When extracting archives:
- Causes
._*
archive members to be extracted as plain files instead of restoring the extended attributes to the related file.
In short, setting these variables makes tar, et al. act like they would on (e.g.) Linux.
If you rarely need to archive files that have extended attributes or resource forks, and you might need to archive or extract actual ._*
files, then you might consider setting and exporting these variables in one of your shell initialization files:
# Tell tar, pax, etc. on Mac OS X 10.4+ not to archive
# extended attributes (e.g. resource forks) to ._* archive members.
# Also allows archiving and extracting actual ._* files.
COPY_EXTENDED_ATTRIBUTES_DISABLE=true COPYFILE_DISABLE=true
export COPY_EXTENDED_ATTRIBUTES_DISABLE COPYFILE_DISABLE
These ._*
files are also used to store extended attributes on filesystems that do not support them—most commonly the FAT variants. These variables will not really help when dealing with ._*
files on other filesystems, just archives.
The HFS+ filesystem used in Mac OS X is perfectly capable of storing actual ._*
files, so once you use the variables to extract the files to the filesystem, the files can be accessed properly in all the normal ways.
Odd that the tar function on mac can't make this distinction. – DaveParillo – 2010-03-15T03:43:43.773
Ironically, there is a question asking how to make
– user1686 – 2011-03-21T09:17:03.550tar
exclude._
files.