6 ms·
Interestingly, it's opened by the same command on both OSes - tar -xf some_file.tar.xz tar -xf some_file.tar.gz
by lqdc13 11y ago
Interestingly, it's opened by the same command on both OSes -
tar -xf some_file.tar.xz
tar -xf some_file.tar.gz
- ymse 11y agoIf you don't explicitly specify (de)compression method (z for gzip, J for xz), tar will try to guess it.
- marcosdumay 11y agoThat's new. Tar didn't use to behave that way, and plenty of people got used to specifying flags.
- neerdowell 11y agoAnd many implementations don't behave that way.
- Freak_NL 11y agoI guess a lot of people are or were used to: tar -xzf file.tar.gz To be honest, I only started doing -xf a year ago. I was used to -xjf and -xzf.
- semi-extrinsic 11y agotar flags must be a prime example of cargo culting. Hands up everyone who's done or seen someone do tar -xzvf file.tgz > /dev/null
- mgkimsal 11y agonever seen that in my life until now - what does it do? Just unzip the file to dev/null? What's the purpose? Does the verbose flag show you what's inside but the dev/null means it's not written to disk while unzipping?
- hobarrera 11y agoActually, the files are decompressed to the current directory, it's the just output of the verbose flag that goes to /dev/null. Which makes is even more senseless.
- semi-extrinsic 11y agoExactly. I've seen people who always do `tar xzvf` and have no idea removing the `v` is the correct way to make it not print the name of every file in the archive.
- merb 11y agoI use the -v switch since I want to see what I decompress, however I didn't knew that I could supress the z switch.
- semi-extrinsic 11y agoIsn't it better though to omit the -v switch and do `ls *` and/or `tree` afterwards? That gives you the same information but structured so it's much easier to understand.
- pwaring 11y agoThe advantage of -v is that you can see what is being extracted as it happens. This is useful if you have a tarball with thousands of small files, as otherwise it's hard to tell whether tar has got stuck or there are just a lot of files.
- bzbarsky 11y agoYou didn't use to be able to suppress the 'z' switch. You had to specify 'z' or 'j' depending on whether you wanted gzip or bzip2 decompression. It's a somewhat recent (sometime in the last 15 years, I think) change to "tar" to make it just detect the compression algorithm.
- hobarrera 11y agoI don't understand why you'd do that. tar does not compress to stdout.
- semi-extrinsic 11y agoRedirecting stdout is to cancel the -v flag (verbose, lists every file extracted).
- hobarrera 11y agoThat's gnu tar. I don't think that works on BSD.
- neerdowell 11y agoCorrect, on OpenBSD: $ tar -xf foo.tar.xz tar: End of archive volume 1 reached tar: input compressed with xz $ tar -xf foo.tar.gz tar: End of archive volume 1 reached tar: input compressed with gzip; use the -z option to decompress it
- faho 11y agoDoes that _tell_ you what it's compressed with but then not decompress it? That's the absolute worst way to do it!
- neerdowell 11y agoIt tells you how it's compressed and how to decompress it if it knows how. OpenBSD's tar doesn't support xz so it can't help there, but does support gzip so it suggests using -z. Not letting untrusted input automatically increase the attack surface it's exposed to is a feature.
- faho 11y ago>Not letting untrusted input automatically increase the attack surface it's exposed to is a feature. How is that a feature? The user's explicitly asking for this. This feature reminds me of vim, that suggests closing with ":quit" when you press C-x C-c (i.e. the keychord to close emacs). It knows full well what you want to do and even has special code to handle it, but then insists to hand you more work.
- neerdowell 11y ago`tar -xf` is not "explicitly asking" for gzip. `tar -zxf` is "explicitly asking" for gzip. I don't really care what vim does, that's a different argument. There have been many vulnerabilities in gzip, and in tar implementations that let untrusted input choose how it gets parsed, those vulnerabilities might as well be in tar itself.