From 36512801945cdd731f44d40abef9ca9dfc212fd1 Mon Sep 17 00:00:00 2001 From: Kyle Laker Date: Mon, 25 Sep 2017 08:36:51 +1000 Subject: [PATCH] whattime: Show 0 minutes in pretty output When supplying the -p command to uptime, it does not display any sections where the value is less than 1; however, after a reboot, this causes the command to just output "up". Showing 0 minutes when the system has been up for less than a minute makes it clear a reboot just occurred. References: commit 325d68b7c39f432a2814f06b00eb0f9a45559c6c Signed-off-by: Craig Small --- proc/uptime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proc/uptime.c b/proc/uptime.c index f91d227f..3a005b82 100644 --- a/proc/uptime.c +++ b/proc/uptime.c @@ -203,10 +203,10 @@ PROCPS_EXPORT char *procps_uptime_sprint_short(void) comma += 1; } - if (upminutes) { + if (upminutes || (!upminutes && uptime_secs < 60)) { pos += sprintf(shortbuf + pos, "%s%d %s", - comma > 0 ? ", " : "", upminutes, - upminutes > 1 ? "minutes" : "minute"); + comma > 0 ? ", " : "", upminutes, + upminutes != 1 ? "minutes" : "minute"); comma += 1; } return shortbuf;