From c20b2f2421011a2c29fa04cc1955ed67b87daeb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 25 May 2022 10:18:14 +0200 Subject: [PATCH] analyze: use '' instead of the empty string when showing versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It looks like garbled output… I didn't use shell-escape, because the other characters that are special for the shell that are used in versions should not be escaped. --- src/analyze/analyze-compare-versions.c | 4 ++-- test/test-compare-versions.sh | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/analyze/analyze-compare-versions.c b/src/analyze/analyze-compare-versions.c index 9545326fa9..acc9bbfcf0 100644 --- a/src/analyze/analyze-compare-versions.c +++ b/src/analyze/analyze-compare-versions.c @@ -16,9 +16,9 @@ int verb_compare_versions(int argc, char *argv[], void *userdata) { if (argc == 3) { r = strverscmp_improved(ASSERT_PTR(argv[1]), ASSERT_PTR(argv[2])); printf("%s %s %s\n", - argv[1], + isempty(argv[1]) ? "''" : argv[1], r < 0 ? "<" : r > 0 ? ">" : "==", - argv[2]); + isempty(argv[2]) ? "''" : argv[2]); /* This matches the exit convention used by rpmdev-vercmp. * We don't use named values because 11 and 12 don't have names. */ diff --git a/test/test-compare-versions.sh b/test/test-compare-versions.sh index 6cfcc158e6..c40208be60 100755 --- a/test/test-compare-versions.sh +++ b/test/test-compare-versions.sh @@ -17,9 +17,10 @@ $ANALYZE compare-versions 1 '!=' 2 ( ! $ANALYZE compare-versions 1 gt 2 ) ( ! $ANALYZE compare-versions 1 '>' 2 ) -$ANALYZE compare-versions 1 2 | grep ' < ' -$ANALYZE compare-versions 2 2 | grep ' == ' -$ANALYZE compare-versions 2 1 | grep ' > ' +test "$($ANALYZE compare-versions 1 2)" = '1 < 2' +test "$($ANALYZE compare-versions 2 2)" = '2 == 2' +test "$($ANALYZE compare-versions 2 1)" = '2 > 1' +test "$($ANALYZE compare-versions '' '')" = "'' == ''" set +e