From owner-freebsd-bugs@FreeBSD.ORG Mon Dec 13 18:10:35 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E195516A57C; Mon, 13 Dec 2004 18:10:34 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B8FF943D60; Mon, 13 Dec 2004 18:10:34 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id iBDIAYQf035340; Mon, 13 Dec 2004 18:10:34 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id iBDIAY1Q035339; Mon, 13 Dec 2004 18:10:34 GMT (envelope-from gnats) Resent-Date: Mon, 13 Dec 2004 18:10:34 GMT Resent-Message-Id: <200412131810.iBDIAY1Q035339@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Cc: paul@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Mikhail Teterin Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3742B16A4CE; Mon, 13 Dec 2004 18:08:12 +0000 (GMT) Received: from out006.verizon.net (out006pub.verizon.net [206.46.170.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id A2D1243D39; Mon, 13 Dec 2004 18:08:11 +0000 (GMT) (envelope-from mteterin@250-217.customer.cloud9.net) Received: from corbulon.video-collage.com ([151.204.231.237]) by out006.verizon.netESMTP <20041213180810.LLCK7873.out006.verizon.net@corbulon.video-collage.com>; Mon, 13 Dec 2004 12:08:10 -0600 Received: from 250-217.customer.cloud9.net (195-11.customer.cloud9.net [168.100.195.11])iBDI89Mn085335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Dec 2004 13:08:10 -0500 (EST) (envelope-from mteterin@250-217.customer.cloud9.net) Received: from 250-217.customer.cloud9.net (mteterin@localhost [127.0.0.1]) iBDI8GGA060938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 13 Dec 2004 13:08:16 -0500 (EST) (envelope-from mteterin@250-217.customer.cloud9.net) Received: (from mteterin@localhost)iBDI8GYj060937; Mon, 13 Dec 2004 13:08:16 -0500 (EST) (envelope-from mteterin) Message-Id: <200412131808.iBDI8GYj060937@250-217.customer.cloud9.net> Date: Mon, 13 Dec 2004 13:08:16 -0500 (EST) From: Mikhail Teterin To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: paul@FreeBSD.org cc: paul@FreeBSD.org Subject: bin/75028: [patch] when following multiple files, tail(1) re-prints file names X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Dec 2004 18:10:35 -0000 >Number: 75028 >Category: bin >Synopsis: [patch] when following multiple files, tail(1) re-prints file names >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Dec 13 18:10:31 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Mikhail Teterin >Release: FreeBSD 5.3-STABLE i386 >Organization: Virtual Estates, Inc. >Environment: 6.x current >Description: The 6.0-current finally has the great feature in the standard tail(1) -- an ability to follow multiple files. Unfortunately, the current implementation re-prints the file-name too often -- whenever a block of lines is read from the file, even if the previous output was ALSO read from the same file. >How-To-Repeat: Try tail -F /COPYRIGHT /var/log/messages You'll see `==> /var/log/messages <==' reprinted for each new addition to the log, even though the previous block of lines was also from the same log (/COPYRIGHT is not, usually, growing). >Fix: The patch below fixes the problem above (second hunk) as well as a few "unused variables" warnings (hunks 1 and 3). [I'm using (and enjoying) this new tail on all of my machines -- 5.x and 4.x included. FreeBSD's veterinarians are the greatest!] cvs diff: Diffing . Index: forward.c =================================================================== RCS file: /meow/ncvs/src/usr.bin/tail/forward.c,v retrieving revision 1.35 diff -U2 -r1.35 forward.c --- forward.c 4 Nov 2004 19:18:19 -0000 1.35 +++ forward.c 11 Nov 2004 19:32:22 -0000 @@ -96,9 +96,5 @@ forward(FILE *fp, enum STYLE style, off_t off, struct stat *sbp) { - int ch, n, kq = -1; - int action = USE_SLEEP; - struct kevent ev[2]; - struct stat sb2; - struct timespec ts; + int ch; switch(style) { @@ -249,11 +245,11 @@ show(file_info_t *file) { - int ch, first; + int ch; + static file_info_t *last; - first = 1; while ((ch = getc(file->fp)) != EOF) { - if (first && no_files > 1) { + if (last != file && no_files > 1) { (void)printf("\n==> %s <==\n", file->file_name); - first = 0; + last = file; } if (putchar(ch) == EOF) @@ -303,7 +299,5 @@ int active, i, n = -1; struct stat sb2; - struct stat *sbp; file_info_t *file; - long spin=1; struct timespec ts; >Release-Note: >Audit-Trail: >Unformatted: