summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.bin/last/last.115
-rw-r--r--usr.bin/last/last.c23
2 files changed, 25 insertions, 13 deletions
diff --git a/usr.bin/last/last.1 b/usr.bin/last/last.1
index fad2f19ee9d..164835407a6 100644
--- a/usr.bin/last/last.1
+++ b/usr.bin/last/last.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: last.1,v 1.20 2003/06/03 02:56:09 millert Exp $
+.\" $OpenBSD: last.1,v 1.21 2004/06/16 22:30:07 millert Exp $
.\" $NetBSD: last.1,v 1.3 1994/12/21 22:41:23 jtc Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
@@ -39,9 +39,10 @@
.Sh SYNOPSIS
.Nm last
.Op Fl csT
-.Op Fl Ns Ar n
+.Op Fl Ns Ar number
.Op Fl f Ar file
.Op Fl h Ar host
+.Op Fl n Ar number
.Op Fl t Ar tty
.Op Fl d Ar [[[CC]YY]MMDD]hhmm[.SS]
.Op Ar user ...
@@ -66,7 +67,11 @@ a crash or shutdown,
will so indicate.
.Pp
The options are as follows:
-.Bl -tag -width Ds
+.Bl -tag -width "-n number"
+.It Fl Ns Ar number
+Same as the
+.Fl n
+option (deprecated).
.It Fl c
Calculates the total time displayed and prints it after the output.
.It Fl f Ar file
@@ -75,9 +80,9 @@ reads the file
.Ar file
instead of the default,
.Pa /var/log/wtmp .
-.It Fl Ar n
+.It Fl n Ar number
Limits the report to
-.Ar n
+.Ar number
lines.
.It Fl s
Display time values in seconds since the epoch, instead of formatted dates.
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index ebc45e2f839..928353b3b6d 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: last.c,v 1.30 2004/01/08 13:36:52 otto Exp $ */
+/* $OpenBSD: last.c,v 1.31 2004/06/16 22:30:08 millert Exp $ */
/* $NetBSD: last.c,v 1.6 1994/12/24 16:49:02 cgd Exp $ */
/*
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)last.c 8.2 (Berkeley) 4/2/94";
#endif
-static char rcsid[] = "$OpenBSD: last.c,v 1.30 2004/01/08 13:36:52 otto Exp $";
+static char rcsid[] = "$OpenBSD: last.c,v 1.31 2004/06/16 22:30:08 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -109,14 +109,13 @@ void usage(void);
int
main(int argc, char *argv[])
{
- extern int optind;
- extern char *optarg;
- int ch;
+ const char *errstr;
char *p;
+ int ch;
maxrec = -1;
snaptime = 0;
- while ((ch = getopt(argc, argv, "0123456789cf:h:st:d:T")) != -1)
+ while ((ch = getopt(argc, argv, "0123456789cf:h:n:st:d:T")) != -1)
switch (ch) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
@@ -130,7 +129,7 @@ main(int argc, char *argv[])
maxrec = atol(++p);
else
maxrec = atol(argv[optind] + 1);
- if (!maxrec)
+ if (maxrec == 0)
exit(0);
}
break;
@@ -144,6 +143,14 @@ main(int argc, char *argv[])
hostconv(optarg);
addarg(HOST_TYPE, optarg);
break;
+ case 'n':
+ maxrec = strtonum(optarg, 0, LONG_MAX, &errstr);
+ if (errstr != NULL)
+ errx(1, "number of lines is %s: %s", errstr,
+ optarg);
+ if (maxrec == 0)
+ exit(0);
+ break;
case 's':
seconds++;
break;
@@ -646,7 +653,7 @@ usage(void)
extern char *__progname;
fprintf(stderr,
- "usage: %s [-#] [-csT] [-f file] [-t tty] [-h host]"
+ "usage: %s [-#] [-csT] [-f file] [-n #] [-t tty] [-h host]"
" [-d [[[CC]YY]MMDD]hhmm[.SS]] [user ...]\n", __progname);
exit(1);
}