diff options
author | Francesco Giudici <fgiudici@redhat.com> | 2017-01-17 11:58:40 +0100 |
---|---|---|
committer | Francesco Giudici <fgiudici@redhat.com> | 2017-03-28 10:55:00 +0200 |
commit | 6520cf11713e0df4195af2214f8dcdd950c00570 (patch) | |
tree | 0339f71a738bbb6a98e3272394e727435a641065 | |
parent | 39f1d44ec8af2f5987b9de74eea0bee225f7da65 (diff) | |
download | NetworkManager-6520cf11713e0df4195af2214f8dcdd950c00570.tar.gz |
nmcli: always print "--" for empty or unset values in normal/pretty output
This was already true for tabular ouput mode.
Align to this behavior when printing in multiline mode.
-rw-r--r-- | clients/cli/settings.c | 7 | ||||
-rw-r--r-- | clients/cli/utils.c | 15 |
2 files changed, 14 insertions, 8 deletions
diff --git a/clients/cli/settings.c b/clients/cli/settings.c index d2d94913e4..87b1f50f71 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -2503,10 +2503,13 @@ nmc_property_connection_get_permissions (NMSetting *setting, NmcPropertyGetType if (nm_setting_connection_get_permission (s_con, i, &perm_type, &perm_item, NULL)) g_string_append_printf (perm, "%s:%s,", perm_type, perm_item); } - if (perm->len > 0) + if (perm->len > 0) { g_string_truncate (perm, perm->len-1); /* remove trailing , */ + return g_string_free (perm, FALSE); + } - return g_string_free (perm, FALSE); + /* No value from get_permission */ + return g_string_free (perm, TRUE); } DEFINE_GETTER (nmc_property_connection_get_zone, NM_SETTING_CONNECTION_ZONE) diff --git a/clients/cli/utils.c b/clients/cli/utils.c index e0b9d1d9a2..93024e2de1 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -1026,10 +1026,13 @@ get_value_to_print (NmCli *nmc, if (field_name) value = _(field->name_l10n); else - value = field->value ? - (is_array ? g_strjoinv (" | ", (char **) field->value) : - (char *) field->value) : - (char *) not_set_str; + value = field->value + ? (is_array + ? g_strjoinv (" | ", (char **) field->value) + : (*((char *) field->value) + ? (char *) field->value + : (char *) not_set_str)) + : (char *) not_set_str; free_value = field->value && is_array && !field_name; /* colorize the value */ @@ -1143,7 +1146,7 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[]) const char *val = (const char*) field_values[idx].value; char *print_val; - val = val ? val : not_set_str; + val = val && *val ? val : not_set_str; print_val = colorize_string (nmc, field_values[idx].color, field_values[idx].color_fmt, val, &free_print_val); tmp = g_strdup_printf ("%s%s%s:", @@ -1192,7 +1195,7 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[]) } else { width1 = strlen (value); width2 = nmc_string_screen_width (value, NULL); /* Width of the string (in screen colums) */ - g_string_append_printf (str, "%-*s", field_values[idx].width + width1 - width2, strlen (value) > 0 ? value : "--"); + g_string_append_printf (str, "%-*s", field_values[idx].width + width1 - width2, strlen (value) > 0 ? value : not_set_str); g_string_append_c (str, ' '); /* Column separator */ table_width += field_values[idx].width + width1 - width2 + 1; } |