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>
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;