Hacker News new | ask | show | jobs
by rileymat1 3842 days ago
Is it likely that a user has gzip on a system but not tar itself? From the article:

What about tooling? OSX: tar -xf some.tar.xz (WORKS!) Linux: tar -xf some.tar.xz (WORKS!) Windows: ? (No idea, I haven't touched the platform in a while... should WORK!)

3 comments

Tar does not implement decompression. If you don't have xz installed it won't work.
That doesn't seem correct, on osx 10.11 `tar xf` can extract `.tar.xz` yet doesn't fork an xz. AFAIK 10.11 doesn't even come with xz.
tar can link the xz lib without forking.
So tar does "implement decompression" (and compression, by delegating the work to libarchive) and it can work even "if you don't have xz installed".
It would require liblzma, but you are correct that the library is a separate thing from the executable xz.
> It would require liblzma

Yep, in the same way it requires libz and libbz2.

IIRC bsdtar (e.g. on OS X) includes xz.
On the vast majority of Linux distributions, you can pretty much guarantee that both tar and zlib will be installed.

Both tend to be part of an essential core of packages required to install a system.

Pretty sure tar -xf does not actually work on osx unless you download a recent tar.
I have tar that came with the system (latest OSX) and tar -xf works just fine. And it did work fine for as long as I can remember.
It does, and should have since at least 10.6 (I can find references to 10.6's tar being built on libarchive and that's one of libarchive's headline features; 10.5 predates libarchive so it may not have supported that)