diff options
author | Daniel Colascione <dancol@dancol.org> | 2015-09-03 01:43:27 (GMT) |
---|---|---|
committer | Daniel Colascione <dancol@dancol.org> | 2015-09-03 01:57:19 (GMT) |
commit | 975c06b1adb2a8741fb1615db4c1e52adbdd540d (patch) | |
tree | a1d9d7752bd9235507ab2eef296c954d7ebe24e4 /programs | |
parent | 6f1fe1b70d49b7be5a354ff41b022748697b5118 (diff) | |
download | lz4-975c06b1adb2a8741fb1615db4c1e52adbdd540d.zip lz4-975c06b1adb2a8741fb1615db4c1e52adbdd540d.tar.gz lz4-975c06b1adb2a8741fb1615db4c1e52adbdd540d.tar.bz2 |
Improve error messages for attempted console IO
Diffstat (limited to 'programs')
-rw-r--r-- | programs/lz4cli.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 0b2ff0e..c82388c 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 output to console\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; |