Add the -n maxrec option as an alias for -maxrec for compatibility with

System V and consistency with other utilities. Document the new form
instead of the old form in the manual page.

PR:		54661
This commit is contained in:
Tim J. Robbins 2003-07-27 10:53:28 +00:00
parent 085f5d6043
commit b28e089684
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118077
2 changed files with 18 additions and 10 deletions

View File

@ -32,7 +32,7 @@
.\" @(#)last.1 8.1 (Berkeley) 6/6/93 .\" @(#)last.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd March 1, 2002 .Dd July 27, 2003
.Dt LAST 1 .Dt LAST 1
.Os .Os
.Sh NAME .Sh NAME
@ -40,7 +40,6 @@
.Nd indicate last logins of users and ttys .Nd indicate last logins of users and ttys
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl Ns Ar n
.Op Fl y .Op Fl y
.Oo .Oo
.Fl d .Fl d
@ -53,6 +52,7 @@
.Oc .Oc
.Op Fl f Ar file .Op Fl f Ar file
.Op Fl h Ar host .Op Fl h Ar host
.Op Fl n Ar maxrec
.Op Fl s .Op Fl s
.Op Fl t Ar tty .Op Fl t Ar tty
.Op Fl w .Op Fl w
@ -78,10 +78,6 @@ will so indicate.
.Pp .Pp
The following options are available: The following options are available:
.Bl -tag -width indent-two .Bl -tag -width indent-two
.It Fl Ar n
Limit the report to
.Ar n
lines.
.It Fl d Ar date .It Fl d Ar date
Specify the snapshot date and time. Specify the snapshot date and time.
All users logged in at the snapshot date and time will All users logged in at the snapshot date and time will
@ -94,7 +90,7 @@ files.
When this argument is provided, all other options except for When this argument is provided, all other options except for
.Fl f .Fl f
and and
.Fl Ar n .Fl n
are ignored. are ignored.
The argument should be in the form The argument should be in the form
.Sm off .Sm off
@ -151,6 +147,10 @@ instead of the default,
.It Fl h Ar host .It Fl h Ar host
.Ar Host .Ar Host
names may be names or internet numbers. names may be names or internet numbers.
.It Fl n Ar maxrec
Limit the report to
.Ar maxrec
lines.
.It Fl s .It Fl s
Report the duration of the login session in seconds, instead of the Report the duration of the login session in seconds, instead of the
default days, hours and minutes. default days, hours and minutes.

View File

@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h> #include <sys/stat.h>
#include <err.h> #include <err.h>
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <langinfo.h> #include <langinfo.h>
#include <locale.h> #include <locale.h>
@ -113,8 +114,8 @@ void
usage(void) usage(void)
{ {
(void)fprintf(stderr, (void)fprintf(stderr,
"usage: last [-#] [-y] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n" "usage: last [-y] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n"
"\t[-t tty] [-s|w] [user ...]\n"); "\t[-n maxrec] [-t tty] [-s|w] [user ...]\n");
exit(1); exit(1);
} }
@ -129,7 +130,7 @@ main(int argc, char *argv[])
maxrec = -1; maxrec = -1;
snaptime = 0; snaptime = 0;
while ((ch = getopt(argc, argv, "0123456789d:f:h:st:wy")) != -1) while ((ch = getopt(argc, argv, "0123456789d:f:h:n:st:wy")) != -1)
switch (ch) { switch (ch) {
case '0': case '1': case '2': case '3': case '4': case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': case '5': case '6': case '7': case '8': case '9':
@ -156,6 +157,13 @@ main(int argc, char *argv[])
hostconv(optarg); hostconv(optarg);
addarg(HOST_TYPE, optarg); addarg(HOST_TYPE, optarg);
break; break;
case 'n':
errno = 0;
maxrec = strtol(optarg, &p, 10);
if (p == optarg || *p != '\0' || errno != 0 ||
maxrec <= 0)
errx(1, "%s: bad line count", optarg);
break;
case 's': case 's':
sflag++; /* Show delta as seconds */ sflag++; /* Show delta as seconds */
break; break;