diff --git a/src/import/export.c b/src/import/export.c index 6f035bf96e..b3edc1a787 100644 --- a/src/import/export.c +++ b/src/import/export.c @@ -18,6 +18,7 @@ #include "runtime-scope.h" #include "signal-util.h" #include "string-util.h" +#include "terminal-util.h" #include "verbs.h" static ImportCompressType arg_compress = IMPORT_COMPRESS_UNKNOWN; @@ -93,6 +94,9 @@ static int export_tar(int argc, char *argv[], void *userdata) { } else { _cleanup_free_ char *pretty = NULL; + if (isatty_safe(STDOUT_FILENO)) + return log_error_errno(SYNTHETIC_ERRNO(EBADF), "Refusing to write archive to TTY."); + fd = STDOUT_FILENO; (void) fd_get_path(fd, &pretty);