Subject: bin/2082: uptime(1)'s output can be confusing if up for less than 1 minute.
To: None <gnats-bugs@NetBSD.ORG>
From: Chris G. Demetriou <cgd@sun-lamp.pc.cs.cmu.edu>
List: netbsd-bugs
Date: 02/15/1996 21:33:04
>Number:         2082
>Category:       bin
>Synopsis:       uptime & w don't print 'time up' if < 1 minute
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 15 21:50:01 1996
>Last-Modified:
>Originator:     Chris G. Demetriou
>Organization:
Kernel Hackers 'r' Us
>Release:        NetBSD-current, February 15, 1996
>Environment:
System: NetBSD sun-lamp.pc.cs.cmu.edu 1.1A NetBSD 1.1A (SUN_LAMP) #34: Thu Jan 18 20:53:30 EST 1996 cgd@sun-lamp.pc.cs.cmu.edu:/usr/src/sys/arch/i386/compile/SUN_LAMP i386


>Description:
	w and uptime normally print system uptime and load in the form:

	21:26  up 31 days,  4:36,  5 users,  load average: 0.01, 0.04, 0.05

	More generally, that's:

	<date> up <time incl. commas>,  <n> user[s],  load average: <averages>

	However, if the system has been up for less than a minute, it'll
	print something like:

	21:26  up,  1 user, load average: 0.15, 0.00, 0.00

	I.e. it no longer prints _anything_ for the 'up time'.

	This confused me (i had to look at the output a couple of times to
	realize what happened).  From talking to others about it, apparently
	i'm not along in thinking the output format odd.  I've no doubt
	that the machine is _up_, since i just ran a command...  8-)

>How-To-Repeat:
	boot a fast machine, and log in, and run 'uptime' or 'w'.  If
	the machine has been up for less than a minute, note that it
	simply says "up," rather than including the amount of time
	that it's been up.

>Fix:
	Apply the following diff:

Index: usr.bin/w/w.c
===================================================================
RCS file: /a/cvsroot/src/usr.bin/w/w.c,v
retrieving revision 1.16
diff -c -r1.16 w.c
*** w.c	1995/05/25 04:02:19	1.16
--- w.c	1996/02/16 02:15:22
***************
*** 380,388 ****
  			if (hrs > 0)
  				(void)printf(" %d hr%s,",
  				    hrs, hrs > 1 ? "s" : "");
! 			if (mins > 0)
  				(void)printf(" %d min%s,",
! 				    mins, mins > 1 ? "s" : "");
  		}
  	}
  
--- 380,388 ----
  			if (hrs > 0)
  				(void)printf(" %d hr%s,",
  				    hrs, hrs > 1 ? "s" : "");
! 			if (mins > 0 || (days == 0 && hrs == 0))
  				(void)printf(" %d min%s,",
! 				    mins, mins != 1 ? "s" : "");
  		}
  	}
  
>Audit-Trail:
>Unformatted: