From 90c1473f515ac0c0936b5c5b0267c43a6808069b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Tue, 24 Feb 2015 13:34:14 +0100 Subject: cli: only warn about duplicated categories in "--order" option (bgo #738613) It was considered as a hard error before, but we can actually only ignore it and warn. Related commit: 40e98f5d685bc41da32f65e6ee3b5ad1b46cca3f --- clients/cli/connections.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 75ad308518..c6d8fa559b 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -9068,7 +9068,7 @@ parse_preferred_connection_order (const char *order, GError **error) const char *str; GArray *order_arr; NmcSortOrder val; - gboolean inverse; + gboolean inverse, unique; int i; strv = nmc_strsplit_set (order, ":", -1); @@ -9103,21 +9103,22 @@ parse_preferred_connection_order (const char *order, GError **error) _("incorrect item '%s' in '--order' option"), *iter); break; } - /* Check duplicates*/ + /* Check for duplicates and issue a warning for them. */ + unique = TRUE; for (i = 0; i < order_arr->len; i++) { if (abs (g_array_index (order_arr, NmcSortOrder, i)) - abs (val) == 0) { - g_array_unref (order_arr); - order_arr = NULL; - g_set_error (error, NMCLI_ERROR, 0, - _("'%s' repeats in '--order' option"), str); - goto end; + g_printerr (_("Warning: '%s' (%u. value) repeats in '--order' option; ignoring it\n"), + *iter, (unsigned) (iter - strv) + 1); + unique = FALSE; + break; } } /* Value is ok and unique, add it to the array */ - g_array_append_val (order_arr, val); + if (unique) + g_array_append_val (order_arr, val); } -end: + g_strfreev (strv); return order_arr; } -- cgit v1.2.1