Re: suggested addition to 'date'

From: Julian Elischer <julian_at_elischer.org>
Date: Fri, 01 Sep 2006 13:06:06 -0700
Oliver Fromme wrote:

>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.
>  
>

NOTHING is unlimitted.
what happens with a 3GB sequence of characters with no newlines?

>Best regards
>   Oliver
>
>  
>
Received on Fri Sep 01 2006 - 18:06:07 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:59 UTC