]> granicus.if.org Git - procps-ng/commitdiff
whattime: Show 0 minutes in pretty output
authorKyle Laker <lakerka@dukes.jmu.edu>
Sun, 24 Sep 2017 22:36:51 +0000 (08:36 +1000)
committerCraig Small <csmall@enc.com.au>
Sun, 24 Sep 2017 22:36:51 +0000 (08:36 +1000)
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 <csmall@enc.com.au>
proc/uptime.c

index f91d227f9ee905d404fc28b2f039c2fe925bedcd..3a005b82898655fb340d92eef0270d5a088c21f1 100644 (file)
@@ -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;