Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 Sep 2006 07:28:35 -0000
From:      Garance A Drosehn <gad@FreeBSD.org>
To:        Peter Jeremy <peterjeremy@optushome.com.au>, freebsd-current@FreeBSD.org
Cc:        Julian Elischer <julian@elischer.org>
Subject:   Adding a '-D date' option to `cat'
Message-ID:  <p06230937c122c6983e00@[128.113.24.47]>
In-Reply-To: <20060904192006.GA3292@turion.vk2pj.dyndns.org>
References:  <200608281545.k7SFjn6l063922@lurza.secnetix.de> <p06230928c11e2298ca97@[128.113.24.47]> <200609020956.54008.Lucas.James@ldjcs.com.au> <20060902031247.GE749@turion.vk2pj.dyndns.org> <20060904192006.GA3292@turion.vk2pj.dyndns.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--============_-1054681193==_============
Content-Type: text/plain; charset="us-ascii" ; format="flowed"

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@rpi.edu
Senior Systems Programmer               or   gad@FreeBSD.org
Rensselaer Polytechnic Institute;             Troy, NY;  USA
--============_-1054681193==_============
Content-Id: <p06230937c122c6983e00@[128.113.24.47].0.0>
Content-Type: application/octet-stream; name="cat-date.diff"
	; x-mac-type="00000000" ; x-mac-creator="00000000"
Content-Disposition: attachment; filename="cat-date.diff"
	; modification-date="Tue, 5 Sep 2006 03:02:57 -0400"
Content-Transfer-Encoding: x-uuencode

begin 644 cat-date.dif
M26YD97@Z(&-A="XQ"CT]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]
M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T*4D-3(&9I;&4Z
M("]H;VUE+VYC=G,O<W)C+V)I;B]C870O8V%T+C$L=@IR971R:65V:6YG(')E
M=FES:6]N(#$N,C4*9&EF9B`M=2`M<C$N,C4@8V%T+C$*+2TM(&-A="XQ"3$V
M($IA;B`R,#`U(#$V.C0Q.C4U("TP,#`P"3$N,C4**RLK(&-A="XQ"34@4V5P
M(#(P,#8@,#<Z,#(Z-38@+3`P,#`*0$`@+3,R+#<@*S,R+#<@0$`*("Y<(B`@
M("`@0"@C*6-A="XQ"3@N,R`H0F5R:V5L97DI(#4O,B\Y-0H@+EPB("1&<F5E
M0E-$.B!S<F,O8FEN+V-A="]C870N,2QV(#$N,C4@,C`P-2\P,2\Q-B`Q-CHT
M,3HU-2!R=2!%>'`@)`H@+EPB"BTN1&0@36%R8V@@,C$L(#(P,#0**RY$9"!3
M97!T96UB97(@-2P@,C`P-@H@+D1T($-!5"`Q"B`N3W,*("Y3:"!.04U%"D!`
M("TT,2PV("LT,2PW($!`"B`N4V@@4UE.3U!325,*("Y.;0H@+D]P($9L(&)E
M;G-T=78**RY/<"!&;"!$($%R(&1A=&5?9F]R;6%T"B`N3W`@07(*("Y3:"!$
M15-#4DE05$E/3@H@5&AE"D!`("TW,RPV("LW-"PS,"!`0`H@+D)L("UT86<@
M+7=I9'1H(&EN9&5N=`H@+DET($9L(&(*($YU;6)E<B!T:&4@;F]N+6)L86YK
M(&]U='!U="!L:6YE<RP@<W1A<G1I;F<@870@,2X**RY)="!&;"!$($%R(&1A
M=&5?9F]R;6%T"BM0<F5F:7@@96%C:"!O=71P=70@;&EN92!W:71H(&$@<W1R
M:6YG('1H870@:6YD:6-A=&5S('1H92!D871E(&%N9"]O<@HK=&EM92!W:&5N
M('1H870@;&EN92!W87,@<F5A9"!B>2!T:&4**RY.;0HK=71I;&ET>2X**U1H
M92!F;W)M870@;V8@=&AA="!P<F5F:7@@:7,@<W!E8VEF:65D(&)Y('1H92!V
M86QU92!O9@HK+D%R(&1A=&5?9F]R;6%T("X**U1H90HK+D%R(&1A=&5?9F]R
M;6%T"BMA<F=U;65N="!M87D@8V]N=&%I;B!A;GD@;V8@=&AE(&-O;G9E<G-I
M;VX@<W!E8VEF:6-A=&EO;G,@9&5S8W)I8F5D(&EN('1H90HK+EAR('-T<F9T
M:6UE(#,**VUA;G5A;"!P86=E+"!A<R!W96QL(&%S(&%N>2!A<F)I=')A<GD@
M=&5X="X**TYO('-E<&%R871O<B!W:6QL(&)E(&EN<V5R=&5D(&)E='=E96X@
M=&AE(&=E;F5R871E9"!P<F5F:7@@86YD('1H90HK<F5M86EN9&5R(&]F('1H
M92!O=71P=70@;&EN92P@<V\@:68@82!S97!A<F%T;W(@:7,@9&5S:7)E9"!T
M:&5N"BMT:&4@=F%L=64@9F]R"BLN07(@9&%T95]F;W)M870**W-H;W5L9"!E
M;F0@=VET:"!A('-P86-E(&]R('1H92!C;VYV97)S:6]N('-P96-I9FEE<B!O
M9@HK+D1Q($QI("5T("X**U1H90HK+D9L('0**V%N9`HK+D9L('8**V]P=&EO
M;G,@9&\@;F]T(&%F9F5C="!A;GD@8VAA<F%C=&5R<R!G96YE<F%T960@8GD@
M=&AE"BLN07(@9&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K
M7V-A="A&24Q%("IF<"D*('L*(`EI;G0@8V@L(&=O8F)L92P@;&EN92P@<')E
M=CL**PET:6UE7W0@;F]W.PHK"6-H87(@9&%T96)U9ELQ,#(T73L*(`H@"2\J
M(%)E<V5T($5/1B!C;VYD:71I;VX@;VX@<W1D:6XN("HO"B`):68@*&9P(#T]
M('-T9&EN("8F(&9E;V8H<W1D:6XI*0I`0"`M,3DX+#8@*S(P-2PQ-2!`0`H@
M"0D)"6EF("AF97)R;W(H<W1D;W5T*2D*(`D)"0D)8G)E86L["B`)"0E]"BL)
M"0EI9B`H9&%T969M="`A/2!.54Q,*2!["BL)"0D)=&EM92@F;F]W*3L**PD)
M"0EI9B`H<W1R9G1I;64H9&%T96)U9BP@<VEZ96]F*&1A=&5B=68I+"!D871E
M9FUT+`HK"0D)"0EL;V-A;'1I;64H)FYO=RDI(#T](#`I"BL)"0D)"65R<G@H
M,2P@(D1A=&4@9F]R;6%T('1O;R!L87)G92(I.PHK"0D)"2AV;VED*69P=71S
M*&1A=&5B=68L('-T9&]U="D["BL)"0D):68@*&9E<G)O<BAS=&1O=70I*0HK
M"0D)"0EB<F5A:SL**PD)"7T*(`D)?0H@"0EI9B`H8V@@/3T@)UQN)RD@>PH@
E"0D):68@*&5F;&%G("8F('!U=&-H87(H)R0G*2`]/2!%3T8I"FED
`
end

--============_-1054681193==_============--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p06230937c122c6983e00>