Bug 39996 - unit-list output column 1 too short for majority of names
Summary: unit-list output column 1 too short for majority of names
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Lennart Poettering
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-11 02:29 UTC by Ruth Ivimey-Cook
Modified: 2012-07-20 14:21 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Ruth Ivimey-Cook 2011-08-11 02:29:56 UTC
The unit-list output includes the name of the unit,but this name is often longer than the 25 character limit allowed in the code. 

Here is a patch that makes this longer (40 chars) for terminals with over 96 character width, and which moves the ellipsis towards the start (33% -> 25%) of the name, as there's often more specific info towards the end of names.

A better solution would be good, but this is better than the current state.

--- systemd-26/src/systemctl.c.orig     2011-08-11 09:33:57.661750769 +0100
+++ systemd-26/src/systemctl.c  2011-08-11 09:51:40.374639451 +0100
@@ -367,9 +367,10 @@
 }

 static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
-        unsigned active_len, sub_len, job_len, n_shown = 0;
+        unsigned unit_len, active_len, sub_len, job_len, n_shown = 0;
         const struct unit_info *u;

+        unit_len = columns()>96 ? 40 : 25;
         active_len = sizeof("ACTIVE")-1;
         sub_len = sizeof("SUB")-1;
         job_len = sizeof("JOB")-1;
@@ -385,7 +386,7 @@
         }

         if (on_tty()) {
-                printf("%-25s %-6s %-*s %-*s %-*s", "UNIT", "LOAD",
+                printf("%-*s %-6s %-*s %-*s %-*s", unit_len, "UNIT", "LOAD",
                        active_len, "ACTIVE", sub_len, "SUB", job_len, "JOB");
                 if (columns() >= 80+12 || arg_full || !arg_no_pager)
                         printf(" %s\n", "DESCRIPTION");
@@ -417,10 +418,10 @@
                 } else
                         on_active = off_active = "";

-                e = arg_full ? NULL : ellipsize(u->id, 25, 33);
+                e = arg_full ? NULL : ellipsize(u->id, unit_len, 25);

-                printf("%-25s %s%-6s%s %s%-*s %-*s%s%n",
-                       e ? e : u->id,
+                printf("%-*s %s%-6s%s %s%-*s %-*s%s%n",
+                       unit_len, e ? e : u->id,
                        on_loaded, u->load_state, off_loaded,
                        on_active, active_len, u->active_state,
                        sub_len, u->sub_state, off_active,
Comment 1 Lennart Poettering 2012-07-20 14:21:19 UTC
Since a while systemctl will size that column automatically based on the available screen estate, so this should be fixed now.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.