From b1cce9a6ad6e2ffe6c6a4eb731d28cd68893e450 Mon Sep 17 00:00:00 2001 From: Tobias Hieta Date: Mon, 8 Jun 2020 14:06:37 +0200 Subject: [PATCH 1/2] Short version string output This adds support for just showing the version string without the full welcome message if the log level is less than the default. That means that you pass -q once and you will just see "1.4.5". This makes it easier to parse in scripts. --- programs/zstdcli.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 70e2b706..6b795bb6 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -544,6 +544,11 @@ static unsigned parseCompressionParameters(const char* stringPtr, ZSTD_compressi static void printVersion(void) { + if (g_displayLevel < DISPLAY_LEVEL_DEFAULT) { + DISPLAYOUT("%s\n", ZSTD_VERSION_STRING); + return; + } + DISPLAYOUT(WELCOME_MESSAGE); if (g_displayLevel >= 3) { /* format support */ From 1c9b1ddac7e817ca47244f0d5a0904784d4e5acc Mon Sep 17 00:00:00 2001 From: Tobias Hieta Date: Thu, 11 Jun 2020 10:56:47 +0200 Subject: [PATCH 2/2] Update version documention with the support for -q --- programs/zstd.1.md | 1 + 1 file changed, 1 insertion(+) diff --git a/programs/zstd.1.md b/programs/zstd.1.md index 943eafb7..176a856c 100644 --- a/programs/zstd.1.md +++ b/programs/zstd.1.md @@ -238,6 +238,7 @@ the last one takes effect. display version number and exit. Advanced : `-vV` also displays supported formats. `-vvV` also displays POSIX support. + `-q` will only display the version number, suitable for machine reading. * `-v`, `--verbose`: verbose mode * `--show-default-cparams`: