From owner-freebsd-current@FreeBSD.ORG Fri Sep 1 17:07:55 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0A60116A4E2; Fri, 1 Sep 2006 17:07:55 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B8B243D73; Fri, 1 Sep 2006 17:07:53 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (qxabuf@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id k81H7YST050629; Fri, 1 Sep 2006 19:07:40 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id k81H7Ych050627; Fri, 1 Sep 2006 19:07:34 +0200 (CEST) (envelope-from olli) From: Oliver Fromme Message-Id: <200609011707.k81H7Ych050627@lurza.secnetix.de> To: julian@elischer.org (Julian Elischer) Date: Fri, 1 Sep 2006 19:07:34 +0200 (CEST) In-Reply-To: <44F86335.70907@elischer.org> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Fri, 01 Sep 2006 19:07:40 +0200 (CEST) X-Mailman-Approved-At: Fri, 01 Sep 2006 17:38:14 +0000 Cc: freebsd-current@freebsd.org Subject: Re: suggested addition to 'date' X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Sep 2006 17:07:55 -0000 Julian Elischer wrote: > Oliver Fromme wrote: > > John Baldwin wrote: > > > Oliver Fromme wrote: > > > > There's another possibility, which doesn't require a new > > > > option letter at all. You could add a new escape sequence > > > > to the format string, e.g. "%*". Whenever date(1) is > > > > called with a format string containing that sequence, it > > > > goes into filter mode and replaces the sequence with the > > > > current line. That would also enable you to be more > > > > flexible with the placement of the timestamps. > > > > For example: > > > > > > > > $ printf 'foo\nbar\nbaz\n' | date +'%H:%M:%S %*' > > > > 16:39:58 foo > > > > 16:39:58 bar > > > > 16:39:58 baz > > > > > > I prefer this of all the suggestions so far. > > > > It's not very difficult, so I created a patch which does > > exactly that (includes an addition for the manpage, too). > > I've submitted it as bin/102609: > > > > http://www.freebsd.org/cgi/query-pr.cgi?pr=102609 > > A couple of comments: > > you don't need to run strftime for each line if the time hasn't changed. > (My original patch checks this) Good idea. I'll update the patch. > What is the effective maximum line length for a single fgetln? It's unlimited. fgetln() allocates sufficient amount of memory dynamically, that's why I used it instead of fgets(). It avoids reinventing the wheel. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "Python is an experiment in how much freedom programmers need. Too much freedom and nobody can read another's code; too little and expressiveness is endangered." -- Guido van Rossum