Adding a '-D date' option to `cat'

From: Garance A Drosehn <gad_at_FreeBSD.org>
Date: Tue, 5 Sep 2006 03:28:21 -0400
In the thread on "Re: suggested addition to 'date'"
     on Sept 5/2006, Peter Jeremy wrote:
>On Sat, 2006-Sep-02 13:12:48 +1000, I (Peter Jeremy) wrote:
>  > The justification for extending date(1) is that it already has the
>  > code to handle date/time stamps.  In reality, this code is all in
>  > strftime(3) and cat(1) already has hooks to insert a string at the
>  > beginning of a line so I believe that the attached patch is more
>  > appropriate
>
>Following some off-list comments, I have updated the patch to
>correct a bug, change the option character to 'D' (for date) and
>provide a man page update.

I have picked up Peter's patch, and spent some time testing it.
About all I changed in the source file was to update the 'usage'
message, and to use errx() instead of err() if the format is too
long.  The update increases the size of /bin/cat by 696 bytes on
i386.  The more I think about this option, the more I think it
would be a useful option to have readily available.

I am slightly tempted to move the call to time()+strftime() into
a separate routine, and call that routine during the processing
of options.  That way, if some user *does* specify a format which
is over 1024 bytes, they'll get an immediate error message.  As
it is, they won't see an error until `cat' actually goes to print
the first line that it has read in.  On the other hand, it seems
pretty unlikely that many people will be triggering that error.

I've also made a number of changes to the description Peter added
to the man page, trying to include several more details.  I am
never happy with man pages that I write though, so I will not be
insulted if anyone wants to change this.

I intend to commit this within a few days, unless there are major
objections to it.  I am posting this HEADSUP under a new subject,
so people can dump all kinds of paint over me before I commit it.

-- 
Garance Alistair Drosehn     =               drosehn_at_rpi.edu
Senior Systems Programmer               or   gad_at_FreeBSD.org
Rensselaer Polytechnic Institute;             Troy, NY;  USA
Received on Tue Sep 05 2006 - 05:28:35 UTC

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