From 5c9fb6f13fda4f13bb4d4203b816a0ca8c895a0e Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Mon, 22 Apr 2024 12:03:10 +0200 Subject: [PATCH] Support = for short options It unifies behavioe with long options and provide compatibility with DNF4 and rpm. Closes: https://github.com/rpm-software-management/dnf5/issues/1353 --- libdnf5-cli/argument_parser.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libdnf5-cli/argument_parser.cpp b/libdnf5-cli/argument_parser.cpp index 1ba51a62e..ee7f3d67b 100644 --- a/libdnf5-cli/argument_parser.cpp +++ b/libdnf5-cli/argument_parser.cpp @@ -553,15 +553,18 @@ int ArgumentParser::NamedArg::parse_short(const char * option, int argc, const c const char * arg_value; int consumed_args; if (has_value) { - if (option[1] != '\0') { - arg_value = option + 1; - consumed_args = 1; - } else { + if (option[1] == '\0') { if (argc < 2) { throw ArgumentParserNamedArgMissingValueError(M_("Missing value for named argument \"-{}\""), *option); } arg_value = argv[1]; consumed_args = 2; + } else if (option[1] == '=') { + arg_value = option + 2; + consumed_args = 1; + } else { + arg_value = option + 1; + consumed_args = 1; } } else { arg_value = const_val.c_str();