From: Yann Collet Date: Wed, 21 Sep 2016 14:05:03 +0000 (+0200) Subject: fixed : cli : forgotten mandatory argument X-Git-Tag: v1.1.0~13^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=714464f05d8715bca185bfb027d9318210beeedb;p=thirdparty%2Fzstd.git fixed : cli : forgotten mandatory argument --- diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 95267aa89..412870e27 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 233f0775a..d94d8fab9 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"