Get mac tar to stop putting ._* filenames in tar archives
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Civilization
--
Chapters
00:00 Get Mac Tar To Stop Putting ._* Filenames In Tar Archives
00:41 Answer 1 Score 0
01:06 Answer 2 Score 0
01:24 Accepted Answer Score 82
03:22 Thank you
--
Full question
https://superuser.com/questions/259703/g...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#macos #filesystems #tar #metadata
#avk47
ACCEPTED ANSWER
Score 82
Per an answer to another question, you can set the undocumented(?) environment variable COPYFILE_DISABLE to prevent several of the system-supplied programs (including tar) from giving special meaning to ._*
archive members. In particular, it will prevent them from:
storing extended attribute data (including resource forks) in
._*
archive members
(i.e. do not “pollute” archives created on Mac OS X but meant for use on other systems), andattempting to extract extended attributes or resources from archive members named like
._*
(i.e. do not misinterpret._*
archive members in archives from other systems).
The value you use for the environment variable is not important (it can even be the empty string). Values like 0
, and false
will not reenable the feature. The only thing that matters is whether the variable is set (you have to “unset” it to reenable the feature).
You can use this variable on individual commands by taking advantage of the ability of Bourne-style shells (sh, ksh, bash, zsh, etc.) to prefix commands with extra environment variables.
COPYFILE_DISABLE=1 tar cf new.tar …
If you run into the problem more often than not, then you might want to set and export this variable in one of your shell’s initialization files.
# turn off special handling of ._* files in tar, etc.
COPYFILE_DISABLE=1; export COPYFILE_DISABLE
When you need to, you can then unset the variable for individual commands.
(unset COPYFILE_DISABLE; tar cf somefile.tar …)
On this Mac OS X 10.6 system, the following commands all seem to know about COPYFILE_DISABLE:
/usr/bin/tar
(a symbolic link tobsdtar
)/usr/bin/bsdtar
/usr/bin/gnutar
/bin/pax
COPYFILE_DISABLE originated in Mac OS X 10.5. If you need to support 10.4, it has COPY_EXTENDED_ATTRIBUTES_DISABLE that works in the same way.
ANSWER 2
Score 0
Not an expert, but a little googling found this: http://www.ofzenandcomputing.com/zanswers/3422
and this: http://hintsforums.macworld.com/archive/index.php/t-28703.html
The second command looks like it could be incorporated into a script... you may not be able to prevent the creation of resource fork files but you can automatically delete them afterwards.
edit: I should have mentioned this may have bad results, use at your own risk.
ANSWER 3
Score 0
You can try compiling your own tar
, or installing it from Macports or Fink if available (Homebrew doesn't have it). With some "luck" it should be ignorant of OS X metadata and skip creating those files.