From 714464f05d8715bca185bfb027d9318210beeedb Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 21 Sep 2016 16:05:03 +0200 Subject: [PATCH] fixed : cli : forgotten mandatory argument --- programs/zstdcli.c | 2 ++ tests/playTests.sh | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 95267aa8..412870e2 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -434,6 +434,8 @@ int main(int argCount, const char* argv[]) filenameTable[filenameIdx++] = argument; } + if (lastCommand) { DISPLAY("error : command must be followed by argument \n"); return 1; } /* forgotten argument */ + /* Welcome message (if verbose) */ DISPLAYLEVEL(3, WELCOME_MESSAGE); diff --git a/tests/playTests.sh b/tests/playTests.sh index 233f0775..d94d8fab 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -59,9 +59,12 @@ rm tmpCompressed $ZSTD tmp -o tmpCompressed ls tmpCompressed # must work $ECHO "test : -o must be followed by filename (must fail)" -$ZSTD tmp -of tmpCompressed && die "-o must be followed by filename" +$ZSTD tmp -of tmpCompressed && die "-o must be followed by filename " $ECHO "test : force write, correct order" $ZSTD tmp -fo tmpCompressed +$ECHO "test : forgotten argument" +cp tmp tmp2 +$ZSTD tmp2 -fo && die "-o must be followed by filename " $ECHO "test : implied stdout when input is stdin" $ECHO bob | $ZSTD | $ZSTD -d $ECHO "test : null-length file roundtrip"