From 031afacb48962e168e10262458fd1d727ba27cb0 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 3 Mar 2012 12:31:49 +0100 Subject: [PATCH] w: align header when from lenght is defined 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 --- w.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/w.c b/w.c index 102c6034..db7d75c7 100644 --- 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 -- 2.40.0