summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2015-09-03 16:33:06 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2015-09-03 16:33:06 (GMT)
commit012ab2f5297bec68602ce1f4b5739beb5b99673e (patch)
tree79d7241f8a9136be3fde6ef76b9ced792168fdcf
parent0011033e331b713212556acf34b427a74d905cd4 (diff)
parent94a0954b1dd2927660886c4ea56d215ae0a8282d (diff)
downloadlz4-012ab2f5297bec68602ce1f4b5739beb5b99673e.zip
lz4-012ab2f5297bec68602ce1f4b5739beb5b99673e.tar.gz
lz4-012ab2f5297bec68602ce1f4b5739beb5b99673e.tar.bz2
Merge pull request #152 from dcolascione/dev
Improve lz4 command line error message when dealing with console IO
-rw-r--r--programs/lz4cli.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/programs/lz4cli.c b/programs/lz4cli.c
index 0b2ff0e..505191b 100644
--- a/programs/lz4cli.c
+++ b/programs/lz4cli.c
@@ -490,7 +490,11 @@ int main(int argc, char** argv)
if(!input_filename) { input_filename=stdinmark; }
/* Check if input is defined as console; trigger an error in this case */
- if (!strcmp(input_filename, stdinmark) && IS_CONSOLE(stdin) ) badusage();
+ if (!strcmp(input_filename, stdinmark) && IS_CONSOLE(stdin) )
+ {
+ DISPLAYLEVEL(1, "refusing to read from a console\n");
+ exit(1);
+ }
/* Check if benchmark is selected */
if (bench)
@@ -536,7 +540,11 @@ int main(int argc, char** argv)
}
/* Check if output is defined as console; trigger an error in this case */
- if (!strcmp(output_filename,stdoutmark) && IS_CONSOLE(stdout) && !forceStdout) badusage();
+ if (!strcmp(output_filename,stdoutmark) && IS_CONSOLE(stdout) && !forceStdout)
+ {
+ DISPLAYLEVEL(1, "refusing to write to console without -c\n");
+ exit(1);
+ }
/* Downgrade notification level in pure pipe mode (stdin + stdout) and multiple file mode */
if (!strcmp(input_filename, stdinmark) && !strcmp(output_filename,stdoutmark) && (displayLevel==2)) displayLevel=1;