From 6d44fd16dc4687d56240e997324deedd392630e3 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Sun, 13 Feb 2011 12:00:12 -1000 Subject: [PATCH] ps: Add the comm keyword which is an alias for ucomm. While I'm here, don't pad the output of ucomm if it's the last column. --- bin/ps/keyword.c | 2 ++ bin/ps/print.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index da9c837094..85d7fe6799 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -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}, diff --git a/bin/ps/print.c b/bin/ps/print.c index 2794b46b60..f7bb1a445c 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -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 -- 2.41.0