Like many programs,
tar checks to see whether its output is going to a terminal device (tty) and modifies its behavior accordingly. In GNU
tar, we can find the relevant code in
check_tty (enum access_mode mode)
/* Refuse to read archive from and write it to a tty. */
if (strcmp (archive_name_array, "-") == 0
&& isatty (mode == ACCESS_READ ? STDIN_FILENO : STDOUT_FILENO))
FATAL_ERROR ((0, 0,
mode == ACCESS_READ
? _("Refusing to read archive contents from terminal "
"(missing -f option?)")
: _("Refusing to write archive contents to terminal "
"(missing -f option?)")));
You will find that once you connect stdout to something, it will happily write to it:
$ tar -cf- .
tar: Refusing to write archive contents to terminal (missing -f option?)
tar: Error is not recoverable: exiting now
$ tar -cf - . | tar -tf -