ps: Add the comm keyword which is an alias for ucomm.
authorPeter Avalos <pavalos@dragonflybsd.org>
Sun, 13 Feb 2011 22:00:12 +0000 (12:00 -1000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Fri, 18 Feb 2011 01:12:48 +0000 (15:12 -1000)
While I'm here, don't pad the output of ucomm if it's the last column.

bin/ps/keyword.c
bin/ps/print.c

index da9c837..85d7fe6 100644 (file)
@@ -87,6 +87,8 @@ static const VAR var[] = {
        {"batch", "BAT", NULL, 0, lpest, NULL, 3, LPOFF(origcpu), UINT, "d", NULL},
        {"blocked", "", "sigmask", 0, NULL, NULL, 0, 0, 0, NULL, NULL},
        {"caught", "", "sigcatch", 0, NULL, NULL, 0, 0, 0, NULL, NULL},
+       {"comm", "COMMAND", NULL, LJUST, ucomm, NULL, MAXCOMLEN, 0, CHAR,
+               NULL, 0},
        {"command", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16, 0, 0, NULL,
                NULL},
        {"cpu", "CPU", NULL, 0, lpest, NULL, 3, LPOFF(estcpu), UINT, "d", NULL},
index 2794b46..f7bb1a4 100644 (file)
@@ -165,7 +165,11 @@ command(const KINFO *k, const struct varent *vent)
 void
 ucomm(const KINFO *k, const struct varent *vent)
 {
-       printf("%-*s", vent->width, make_printable(KI_PROC(k, comm)));
+       /* Do not pad the last field */
+       if (STAILQ_NEXT(vent, link) == NULL)
+               printf("%s", make_printable(KI_PROC(k, comm)));
+       else
+               printf("%-*s", vent->width, make_printable(KI_PROC(k, comm)));
 }
 
 void