From 325d68b7c39f432a2814f06b00eb0f9a45559c6c Mon Sep 17 00:00:00 2001 From: Kyle Laker Date: Thu, 23 Mar 2017 10:53:55 -0400 Subject: [PATCH 1/2] 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. --- proc/whattime.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proc/whattime.c b/proc/whattime.c index eb345fb1..10e78c3f 100644 --- a/proc/whattime.c +++ b/proc/whattime.c @@ -146,10 +146,10 @@ char *sprint_uptime(int human_readable) { comma += 1; } - if (upminutes) { - pos += sprintf(buf + pos, "%s%d %s", comma > 0 ? ", " : "", upminutes, - upminutes > 1 ? "minutes" : "minute"); - comma += 1; + if (upminutes || (!upminutes && uptime_secs < 60)) { + pos += sprintf(buf + pos, "%s%d %s", comma > 0 ? ", " : "", upminutes, + upminutes != 1 ? "minutes" : "minute"); + comma += 1; } } From 5979696adad7624e0e4ad934bd4d9b4d5e4ba23e Mon Sep 17 00:00:00 2001 From: Kyle Laker Date: Thu, 23 Mar 2017 13:26:46 -0400 Subject: [PATCH 2/2] whattime: Fix formatting Update formatting within the if block to two spaces --- proc/whattime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proc/whattime.c b/proc/whattime.c index 10e78c3f..f55f3636 100644 --- a/proc/whattime.c +++ b/proc/whattime.c @@ -147,9 +147,9 @@ char *sprint_uptime(int human_readable) { } if (upminutes || (!upminutes && uptime_secs < 60)) { - pos += sprintf(buf + pos, "%s%d %s", comma > 0 ? ", " : "", upminutes, - upminutes != 1 ? "minutes" : "minute"); - comma += 1; + pos += sprintf(buf + pos, "%s%d %s", comma > 0 ? ", " : "", upminutes, + upminutes != 1 ? "minutes" : "minute"); + comma += 1; } }