svn commit: r247274 - in head: bin/test tools/regression/bin/test

Greg 'groggy' Lehey grog at FreeBSD.org
Wed Feb 27 00:01:28 UTC 2013


On Tuesday, 26 February 2013 at  1:02:27 +0100, Jilles Tjoelker wrote:
> On Mon, Feb 25, 2013 at 07:05:41PM +0000, Peter Jeremy wrote:
>> Author: peterj
>> Date: Mon Feb 25 19:05:40 2013
>> New Revision: 247274
>> URL: http://svnweb.freebsd.org/changeset/base/247274
>
>> Log:
>>   Enhance test(1) by adding provision to compare any combination of the
>>   access, birth, change and modify times of two files, instead of only
>>   being able to compare modify times.  The builtin test in sh(1) will
>>   automagically acquire the same expansion.
>
>>   Approved by:	grog
>>   MFC after:	2 weeks
>
> What do you need this for?

Lots of things.  For example, I need it to compare photos I have
created and then set the timestamp to the time of exposure.  The only
way I can establish that the image is newer is via the creation
timestamp.  In the past I've wished I had the functionality for other
reasons I now forget.  Peter has other reasons again.  I expect other
users to also find this useful.

Arguably comparing different kinds of timestamps is not very useful,
but then, that's "arguably".  Others might find a use for it.

> If it is not needed very often, this test can
> be done more portably (older FreeBSD and GNU) as
>   [ -n "$(find -L FILE1 -prune -newerXY FILE2 2>/dev/null)" ]

That's really ugly.  It's also difficult for the casual reader to
understand.

> I have generally been rather reluctant in adding things to sh(1) and
> even more so if they are completely new. Someone proposed something
> rather similar (except that it added a time string parser -- even more
> code) in PR bin/57054 and I rejected it in 2009.

That was a much larger chunk of code.  And times change.  In December
1998 I added an -S option to ls(1), and jkh (my mentor) refused it on
the basis of bloat.  In June 2005, keramida submitted similar
functionality, and it was committed as revision 146924.  It's also
functionality that I use frequently.

Re bloat.  Here's before and after:

   text    data     bss     dec     hex filename
  25645    1152    4720   31517    7b1d /bin/ls
  26718    1168    4840   32726    7fd6 /bin/ls

A little over a kilobyte.  Peter even went to the trouble of keeping
the size of the operator table entries the same.  I think the
additional size is justifiable.

Greg
--
Sent from my desktop computer.
Finger grog at FreeBSD.org for PGP public key.
See complete headers for address and phone numbers.
This message is digitally signed.  If your Microsoft MUA reports
problems, please read http://tinyurl.com/broken-mua
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20130227/dc068869/attachment.sig>


More information about the svn-src-all mailing list