libarchive
libarchive copied to clipboard
Creating a tar archive with --no-xattr doesn't exclude extended attributes
On MacOS 15.2 compiled from Homebrew, when creating a tar archive with the tar command, --no-xattr doesn't ignore extended attributes of files.
$ tar --version
bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.12 liblzma/5.4.3 bz2lib/1.0.8
$ touch test
# Add an extended attribute
$ xattr -w hello world test
# Verify that it was added
$ xattr -l test
hello: world
$ tar -c --no-xattr -f test.tar test
# Extract it to a new directory
$ mkdir a
$ tar -xf test.tar -C a
# Extended attribute is still there despite --no-xattr
$ xattr -l a/test
hello: world
On macOS, tar has two ways of storing extended attributes: as extended attributes and in AppleDouble format. By default it does both. --no-xattr disables only the former. --no-mac-metadata disables only the latter.
To exclude all extended attributes, in your example above, you can use:
$ tar -c --no-xattr --no-mac-metadata -f test.tar test