diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-05-06 14:48:54 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-05-06 15:40:15 +0200 |
commit | 50098d87fbe677bd43cb7329b2e32b039401f35c (patch) | |
tree | a7aac0b9f3f85236591dc1347ab315bfbdbdb2b4 /src/systemctl | |
parent | bc04bb0d29623669eac0b514987128016b0c8b47 (diff) | |
download | systemd-50098d87fbe677bd43cb7329b2e32b039401f35c.tar.gz |
systemctl: let's tweak how we synthesize a cell for activating unit
Let's create a string cell for the unit if possible (since there can
only be one unit right now, and the JSON alternative output then
generates a string instead of an array for us), an empty cell if empty.
Diffstat (limited to 'src/systemctl')
-rw-r--r-- | src/systemctl/systemctl.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 673f29bcaa..07b0fdd2c5 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -1027,7 +1027,7 @@ static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) { if (cs) { for (s = socket_infos; s < socket_infos + cs; s++) { - _cleanup_free_ char *j = NULL, *activates = NULL; + _cleanup_free_ char *j = NULL; const char *path; if (s->machine) { @@ -1038,17 +1038,25 @@ static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) { } else path = s->path; - activates = strv_join(s->triggered, ", "); - if (!activates) - return log_oom(); - r = table_add_many(table, TABLE_STRING, path, TABLE_STRING, s->type, - TABLE_STRING, s->id, - TABLE_STRING, activates); + TABLE_STRING, s->id); if (r < 0) return table_log_add_error(r); + + if (strv_isempty(s->triggered)) + r = table_add_cell(table, NULL, TABLE_EMPTY, NULL); + else if (strv_length(s->triggered) == 1) + r = table_add_cell(table, NULL, TABLE_STRING, s->triggered[0]); + else + /* This should never happen, currently our socket units can only trigger a + * single unit. But let's handle this anyway, who knows what the future + * brings? */ + r = table_add_cell(table, NULL, TABLE_STRV, s->triggered); + if (r < 0) + return table_log_add_error(r); + } on = ansi_highlight(); |