summaryrefslogtreecommitdiffstats
path: root/usr.bin/last/last.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2003-07-27 10:53:28 +0000
committertjr <tjr@FreeBSD.org>2003-07-27 10:53:28 +0000
commit5ba14c839731d32ef33fc1489bc286c786165100 (patch)
treeb1d48ace5e5293a5e38bd62a33fab42b6efca427 /usr.bin/last/last.c
parente7241bd66acc2bf0481c0293ad24a89b70fe73a3 (diff)
downloadFreeBSD-src-5ba14c839731d32ef33fc1489bc286c786165100.zip
FreeBSD-src-5ba14c839731d32ef33fc1489bc286c786165100.tar.gz
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
Diffstat (limited to 'usr.bin/last/last.c')
-rw-r--r--usr.bin/last/last.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index 07844a6..8f1cd8a 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <langinfo.h>
#include <locale.h>
@@ -113,8 +114,8 @@ void
usage(void)
{
(void)fprintf(stderr,
-"usage: last [-#] [-y] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n"
-"\t[-t tty] [-s|w] [user ...]\n");
+"usage: last [-y] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n"
+"\t[-n maxrec] [-t tty] [-s|w] [user ...]\n");
exit(1);
}
@@ -129,7 +130,7 @@ main(int argc, char *argv[])
maxrec = -1;
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) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
@@ -156,6 +157,13 @@ main(int argc, char *argv[])
hostconv(optarg);
addarg(HOST_TYPE, optarg);
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':
sflag++; /* Show delta as seconds */
break;
OpenPOWER on IntegriCloud