about summary refs log tree commit diff
path: root/src/nmcli/nmcli.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2024-09-01 22:38:35 +0200
committerMichael Biebl <biebl@debian.org>2024-09-01 22:38:35 +0200
commitf9bfd1158b8d08d6a5ed3bb7cc1ba7a6455e5201 (patch)
tree10267dcf5b842b7c638a79bd6851549cd849b81d /src/nmcli/nmcli.c
parent681dfc70ef98f6ed0c05bcb0fbff00e3fc0799ea (diff)
New upstream version 1.49.90 upstream/1.49.90
Diffstat (limited to 'src/nmcli/nmcli.c')
-rw-r--r--src/nmcli/nmcli.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/nmcli/nmcli.c b/src/nmcli/nmcli.c
index be177847..cfe4c5f4 100644
--- a/src/nmcli/nmcli.c
+++ b/src/nmcli/nmcli.c
@@ -163,17 +163,18 @@ complete_one(gpointer key, gpointer value, gpointer user_data)
         last = prefix;
 
     if ((!*last && !strchr(name, '.')) || matches(last, name)) {
-        if (option != prefix) {
+        if (!nm_streq0(option, prefix)) {
             /* value prefix was not a standalone argument,
              * it was part of --option=<value> argument.
              * Repeat the part leading to "=". */
-            nmc_print("%s=", option);
+            nmc_print("%s\n", option);
+        } else {
+            nmc_print("%.*s%s%s\n",
+                      (int) (last - prefix),
+                      prefix,
+                      name,
+                      nm_streq(last, name) ? "," : "");
         }
-        nmc_print("%.*s%s%s\n",
-                  (int) (last - prefix),
-                  prefix,
-                  name,
-                  strcmp(last, name) == 0 ? "," : "");
     }
 }
 
@@ -225,13 +226,14 @@ complete_option_with_value(const char *option, const char *prefix, ...)
     va_start(args, prefix);
     while ((candidate = va_arg(args, const char *))) {
         if (!*prefix || matches(prefix, candidate)) {
-            if (option != prefix) {
+            if (!nm_streq0(option, prefix)) {
                 /* value prefix was not a standalone argument,
                  * it was part of --option=<value> argument.
                  * Repeat the part leading to "=". */
-                nmc_print("%s=", option);
+                nmc_print("%s%s\n", option, candidate + strlen(prefix));
+            } else {
+                nmc_print("%s\n", candidate);
             }
-            nmc_print("%s\n", candidate);
         }
     }
     va_end(args);
@@ -1044,6 +1046,8 @@ main(int argc, char *argv[])
     if (process_command_line(&nm_cli, argc, argv))
         g_main_loop_run(loop);
 
+    nmc_cleanup_readline();
+
     if (nm_cli.complete) {
         /* Remove error statuses from command completion runs. */
         if (nm_cli.return_value < NMC_RESULT_COMPLETE_FILE)