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
dev
Topher Lubaway 2018-06-11 10:13:00 -07:00
parent 170f948eee
commit 4c16608e3c
1 changed files with 5 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include "platform.h" /* Large Files support, SET_BINARY_MODE */
#include "util.h" /* UTIL_getFileSize, UTIL_isRegularFile */
#include <stdio.h> /* fprintf, fopen, fread, _fileno, stdin, stdout */
#include <unistd.h> /* isatty */
#include <stdlib.h> /* malloc, free */
#include <string.h> /* strcmp, strlen */
#include <errno.h> /* 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;