Preferences

Relevant XKCD

Https://xkcd.com/1168/


To quote bash.org (or qdb.us?), you have to talk to tar with a German accent:

    tar xzf file.tgz
where xzf stands for "extrakt ze feil"
It's `xaf`, because the modern world is way too complex for simple Germanic rules to solve it.

But GNU tar was never the issue. It's almost completely straight forward, the only problem it has is people confusing the tar file with the target directory. If you use some UNIX tar, you will understand why everybody hates it.

Someone once tried this on me during Friday drinks and I successfully conquered the challenge with "tar --help". The challenger tried in vain to claim that this was not valid, but everyone present agreed that an exit code of zero meant that it was a valid solution.

  $ tar --help
  tar: unknown option -- -
  usage: tar {crtux}[014578beFfHhjLmNOoPpqsvwXZz]
             [blocking-factor | format | archive | replstr]
             [-C directory] [-I file] [file ...]
         tar {-crtux} [-014578eHhjLmNOoPpqvwXZz] [-b blocking-factor]
             [-C directory] [-F format] [-f archive] [-I file]
             [-s replstr] [file ...]
  $ echo $?
  1
That is not GNU tar's output. You might wanna make sure your installation is ok.

edit: maybe i missed the joke?

Some drunks in a gnu-shaped echo chamber concluded that the world is gnu-shaped. That's not much a joke, if there is one here. Such presently popular axioms as "unix means linux" or "the userland must be gnu" or "bash is installed" can be shown as poor foundations to reason from by using a unix system that violates all those assumptions. That the XCDD comic did not define what a unix system is is another concern; there are various definitions, some of which would exclude both linux and OpenBSD.
Out of curiosity, what OS are you using?
> maybe i missed the joke?

the bomb specifies only "unix" so you can't assume GNU (which, aha, is Not Unix)

This works with GNU tar, but likely not with tar on other Unix systems.

"tar cf /tmp/a.tar $HOME" would, I guess, work on all POSIX systems.

I seem to remember "tar xvf filename.tar" from the 1990s, I'll try that out. If I'm wrong, I'll be dead before I even notice anything. That's better than dying of cancer or Alzheimer's.
I still do that at least once a week. Along with "tar xzpvf" or more complex invocations like:

    tar cvf - -C /foo/bar baz | zstd > foo.tar.zstd

    tar zxvf
Is burnt into my brain. One of my earliest Linux command line experience required untaring zipped tars.

So yeah that xkcd is "not funny" to me in that sense. Of course I couldn't tell you pretty much any other use without a man page.

z requires it's compressed with gzip and is likely a GNU extension too (it was j for bzip2 iirc). It's also important to keep f the last because it is parametrized and a filename should follow.

So I'd always go with c (create) instead of x (extract), as the latter assumes an existing tar file (zx or xz even a gzipped tar file too; not sure if it's smart enough to autodetect compress-ed .Z files vs .gz either): with create, higher chances of survival in that xkcd.

    tar xvzf file.name
is always a valid command, whether file.name exists or not. When the file doesn't exist, tar will exit with status '2', apparently, but that has no bearing on the validity of the command.

Compare these two logs:

    $ tar xvzf read.me
    tar (child): read.me: Cannot open: No such file or directory
    tar (child): Error is not recoverable: exiting now
    tar: Child returned status 2
    tar: Error is not recoverable: exiting now

    $ tar extract read.me
    tar: invalid option -- 'e'
    Try 'tar --help' or 'tar --usage' for more information.
Do you really not understand the difference between "you told me to do something, but I can't" and "you just spouted some meaningless gibberish"?
The GGP set the benchmark at "returns exit code 0" (for "--help"), and even with XKCD, the term in use is "valid command" which can be interpreted either way.

The rest of your slight is unneccessary, but that's your choice to be nasty.

Like I said, I was operating on a lot of zipped tars. Not sure what you are replying about.

The other commenter already mentioned that the xkcd just said "valid", not return 0 (which to be fair is what the original non xkcd required so I guess fair on the mixup)

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal