summaryrefslogtreecommitdiff
path: root/usr.bin/tail/tail.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tail/tail.c')
-rw-r--r--usr.bin/tail/tail.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/usr.bin/tail/tail.c b/usr.bin/tail/tail.c
index 2246e7b77db..10d164290cd 100644
--- a/usr.bin/tail/tail.c
+++ b/usr.bin/tail/tail.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tail.c,v 1.14 2007/10/31 16:29:50 jmc Exp $ */
+/* $OpenBSD: tail.c,v 1.15 2008/10/17 11:38:20 landry Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)tail.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: tail.c,v 1.14 2007/10/31 16:29:50 jmc Exp $";
+static char rcsid[] = "$OpenBSD: tail.c,v 1.15 2008/10/17 11:38:20 landry Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -132,10 +132,6 @@ main(int argc, char *argv[])
}
argc -= optind;
argv += optind;
-
- if (fflag && argc > 1)
- errx(1, "-f option only appropriate for a single file");
-
/*
* If displaying in reverse, don't permit follow option, and convert
* style values.
@@ -162,27 +158,33 @@ main(int argc, char *argv[])
style = RLINES;
}
}
+
+ if (*argv) {
+ if (fflag) {
+ follow(argv, argc, style, off);
+ }
+ else {
+ for (first = 1; (fname = *argv++);) {
+ if ((fp = fopen(fname, "r")) == NULL ||
+ fstat(fileno(fp), &sb)) {
+ ierr();
+ continue;
+ }
+ if (argc > 1) {
+ (void)printf("%s==> %s <==\n",
+ first ? "" : "\n", fname);
+ first = 0;
+ (void)fflush(stdout);
+ }
- if (*argv)
- for (first = 1; (fname = *argv++);) {
- if ((fp = fopen(fname, "r")) == NULL ||
- fstat(fileno(fp), &sb)) {
- ierr();
- continue;
+ if (rflag)
+ reverse(fp, style, off, &sb);
+ else
+ forward(fp, style, off, &sb);
+ (void)fclose(fp);
}
- if (argc > 1) {
- (void)printf("%s==> %s <==\n",
- first ? "" : "\n", fname);
- first = 0;
- (void)fflush(stdout);
- }
-
- if (rflag)
- reverse(fp, style, off, &sb);
- else
- forward(fp, style, off, &sb);
- (void)fclose(fp);
}
+ }
else {
fname = "stdin";
is_stdin = 1;