statement
SCCS-vsn: usr.bin/tail/tail.c 5.9
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)tail.c 5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)tail.c 5.9 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
static void obsolete __P((char **));
static void usage __P((void));
static void obsolete __P((char **));
static void usage __P((void));
main(argc, argv)
int argc;
main(argc, argv)
int argc;
{
struct stat sb;
FILE *fp;
{
struct stat sb;
FILE *fp;
argc -= optind;
argv += optind;
argc -= optind;
argv += optind;
+ if (fflag && argc > 1)
+ err(1, "-f option only appropriate for a single file");
+
/*
* If displaying in reverse, don't permit follow option, and convert
* style values.
/*
* If displaying in reverse, don't permit follow option, and convert
* style values.
usage();
if (style == FBYTES)
style = RBYTES;
usage();
if (style == FBYTES)
style = RBYTES;
+ else if (style == FLINES)
if (*argv)
for (first = 1; fname = *argv++;) {
if (*argv)
for (first = 1; fname = *argv++;) {
- if ((fp = fopen(fname, "r")) == NULL) {
+ if ((fp = fopen(fname, "r")) == NULL ||
+ fstat(fileno(fp), &sb)) {
reverse(fp, style, off, &sb);
else
forward(fp, style, off, &sb);
reverse(fp, style, off, &sb);
else
forward(fp, style, off, &sb);
- if (fstat(fileno(fp), &sb)) {
+ if (fstat(fileno(stdin), &sb)) {
* Determine if input is a pipe. 4.4BSD will set the SOCKET
* bit in the st_mode field for pipes. Fix this then.
*/
* Determine if input is a pipe. 4.4BSD will set the SOCKET
* bit in the st_mode field for pipes. Fix this then.
*/
- if (lseek(fileno(fp), 0L, SEEK_CUR) == -1 && errno == ESPIPE) {
+ if (lseek(fileno(stdin), 0L, SEEK_CUR) == -1 &&
+ errno == ESPIPE) {
errno = 0;
fflag = 0; /* POSIX.2 requires this. */
}
if (rflag)
errno = 0;
fflag = 0; /* POSIX.2 requires this. */
}
if (rflag)
- reverse(fp, style, off, &sb);
+ reverse(stdin, style, off, &sb);
- forward(fp, style, off, &sb);
+ forward(stdin, style, off, &sb);
*/
static void
obsolete(argv)
*/
static void
obsolete(argv)
{
register char *ap, *p, *t;
int len;
{
register char *ap, *p, *t;
int len;
usage()
{
(void)fprintf(stderr,
usage()
{
(void)fprintf(stderr,
- "usage: tail [-f | -r] [-b # | -c # | -n #] [file]\n");
+ "usage: tail [-f | -r] [-b # | -c # | -n #] [file ...]\n");