From: Topher Lubaway Date: Mon, 11 Jun 2018 17:13:00 +0000 (-0700) Subject: Improves UX for --list command's lack of support for pipes X-Git-Tag: v1.3.5~3^2~14^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c16608e3cb1fae8008466cc8684b8ea0e1d8449;p=thirdparty%2Fzstd.git Improves UX for --list command's lack of support for pipes --list does not support piped input This checks for a terminal and exits 1 with a well formatted error message if the STDIN is not from a terminal --- diff --git a/programs/fileio.c b/programs/fileio.c index b1d2a2415..a9833ae5e 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -27,6 +27,7 @@ #include "platform.h" /* Large Files support, SET_BINARY_MODE */ #include "util.h" /* UTIL_getFileSize, UTIL_isRegularFile */ #include /* fprintf, fopen, fread, _fileno, stdin, stdout */ +#include /* isatty */ #include /* malloc, free */ #include /* strcmp, strlen */ #include /* errno */ @@ -2030,6 +2031,10 @@ static int FIO_listFile(fileInfo_t* total, const char* inFileName, int displayLe } int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel){ + if (!isatty(0)) + DISPLAYOUT("zstd --list does not support reading from standard input\n"); + return 1; + if (numFiles == 0) { DISPLAYOUT("No files given\n"); return 0;