1
0
mirror of https://github.com/systemd/systemd synced 2025-09-30 09:14:46 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Lennart Poettering
228f5ed3a4
Merge pull request #18518 from poettering/inhibit-limit-columns
put a width limit on the "systemd-inhibit --list" table
2021-02-09 17:14:25 +01:00
Lennart Poettering
619b0c077c inhibit: cut off overly long "who" fields
systemd-inhibit when invoked with a command line will put the whole
command line in the "who" field of the inhibitor lock. This can get
extremely long for shell expressions, making the table "systemd-inhibit
--list" shows ridiculously weirdly formatted. Let's put a limit on the
column width: half of the screen, not more.
2021-02-09 15:06:25 +01:00
Lennart Poettering
2cd9f773e2 format-table: don't hit assert if column got less width than it asked for
If one field in a specific column has a maximum size limit, other fields
in the same column might affected by it and get less than they asked
for. Let's make sure we can handle this, and don't assert on this
because surprisingly we got less than what we asked for.
2021-02-09 15:05:25 +01:00
2 changed files with 2 additions and 2 deletions

View File

@ -90,6 +90,7 @@ static int print_inhibitors(sd_bus *bus) {
/* If there's not enough space, shorten the "WHY" column, as it's little more than an explaining comment. */ /* If there's not enough space, shorten the "WHY" column, as it's little more than an explaining comment. */
(void) table_set_weight(table, TABLE_HEADER_CELL(6), 20); (void) table_set_weight(table, TABLE_HEADER_CELL(6), 20);
(void) table_set_maximum_width(table, TABLE_HEADER_CELL(0), columns()/2);
r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssuu)"); r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssuu)");
if (r < 0) if (r < 0)

View File

@ -1993,8 +1993,7 @@ int table_print(Table *t, FILE *f) {
if (width[j] < minimum_width[j]) if (width[j] < minimum_width[j])
width[j] = minimum_width[j]; width[j] = minimum_width[j];
assert(width[j] >= requested_width[j]); delta = LESS_BY(width[j], requested_width[j]);
delta = width[j] - requested_width[j];
/* Subtract what we just added from the rest */ /* Subtract what we just added from the rest */
if (extra > delta) if (extra > delta)