]> granicus.if.org Git - procps-ng/commitdiff
w: align header when from lenght is defined
authorSami Kerola <kerolasa@iki.fi>
Sat, 3 Mar 2012 11:31:49 +0000 (12:31 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 4 Mar 2012 11:12:42 +0000 (12:12 +0100)
Before this commit header and output was not in sync if
PROCPS_FROMLEN environment variable where defined.  Example of wrong
behavior is below where the last four fields which are skewed.

$ PROCPS_FROMLEN=18 w -f | cat
 12:31:34 up  1:25,  1 user,  load average: 0.03, 0.06, 0.06
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
sake     tty1     -                  11:06    1:25m  3.76s  0.00s xinit /ho[...]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
w.c

diff --git a/w.c b/w.c
index 102c603482d7ae651c596f6ec92e51da8414823c..db7d75c7bab3c9aa22cb13fb8759c4c37549bd58 100644 (file)
--- a/w.c
+++ b/w.c
@@ -436,7 +436,7 @@ int main(int argc, char **argv)
                 * headers. Try to keep alignment intact.  */
                printf(_("%-*s TTY      "), userlen, _("USER"));
                if (from)
-                       printf(_("FROM            "));
+                       printf("%-*s", fromlen - 1, _("FROM"));
                if (longform)
                        printf(_("  LOGIN@   IDLE   JCPU   PCPU WHAT\n"));
                else