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