diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 31b06d67be5..820b23b1221 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -148,7 +148,7 @@ static void usage(FILE* f, const char* programName) DISPLAY_F(f, "Compress or decompress the INPUT file(s); reads from STDIN if INPUT is `-` or not provided.\n\n"); DISPLAY_F(f, "Usage: %s [OPTIONS...] [INPUT... | -] [-o OUTPUT]\n\n", programName); DISPLAY_F(f, "Options:\n"); - DISPLAY_F(f, " -o OUTPUT Write output to a single file, OUTPUT.\n"); + DISPLAY_F(f, " -o, --output OUTPUT Write output to a single file, OUTPUT.\n"); DISPLAY_F(f, " -c, --stdout Write to STDOUT (even if it is a console) and keep the INPUT file(s).\n"); DISPLAY_F(f, " -k, --keep Preserve INPUT file(s). [Default] \n"); DISPLAY_F(f, " --rm Remove INPUT file(s) after successful (de)compression to file.\n"); @@ -1139,6 +1139,7 @@ int main(int argCount, const char* argv[]) continue; } #endif + if (longCommandWArg(&argument, "--output")) { NEXT_FIELD(outFileName); continue; } #ifndef ZSTD_NOTRACE if (longCommandWArg(&argument, "--trace")) { char const* traceFile; NEXT_FIELD(traceFile); TRACE_enable(traceFile); continue; } #endif diff --git a/tests/cli-tests/basic/output.sh b/tests/cli-tests/basic/output.sh new file mode 100755 index 00000000000..74a94c57e80 --- /dev/null +++ b/tests/cli-tests/basic/output.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +echo "some data" > file + +println "+ zstd -q file --output compressed.zst" +zstd -q file --output compressed.zst +test -f compressed.zst || die "Expected --output to create compressed.zst" + +println "+ zstd -q -d compressed.zst --output roundtrip" +zstd -q -d compressed.zst --output roundtrip +cmp file roundtrip || die "Expected --output decompression to round-trip" + +exit 0