bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #13212] -newer only examines it's target once at the start


From: anonymous
Subject: [bug #13212] -newer only examines it's target once at the start
Date: Fri, 27 May 2005 19:48:57 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

URL:
  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=13212>

                 Summary: -newer only examines it's target once at the start
                 Project: findutils
            Submitted by: None
            Submitted on: Fri 05/27/2005 at 15:48
                Category: find
                Severity: 3 - Normal
              Item Group: Wrong result
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: Barry Dobyns
        Originator Email: address@hidden
             Open/Closed: Open
                 Release: 4.1.20
           Fixed Release: None

    _______________________________________________________

Details:

Actually Release 4.1.7, debian woody.  Debian is always so up-to-date.

-newer only examines the target once

Consider the case where I'm trying to write a script that sets some "target"
file to the latest time of a large number of other files that I'm using find
to traverse.  

I write 

find $START -f -newer $TARGET -exec touch -r "{}" $TARGET ";"

but this only gets the time set to the last file that find examines  that was
-newer than the $TARGET's mod time before the command began to execute.

My work-around for the line above is to execute until it produces no output,
but that's unpleasant, especially if the structure traversed by find is
large.

while true
do
   findout=`find $START -f -newer $TARGET \
            -exec touch -r "{}" $TARGET ";" -print | tail -1`
   if [ -z $findout ] ; then break ; fi
done

After some reflection, I believe that the general case of this sort of
problem occur when I'm using -exec.

So, I can understand a line of argument that goes that mine is an exceptional
case, and the current behavior of -newer works well for everyone else in the
world.  Indeed, in the general case where the action of the -exec command
does not modify one of the predicates, only taking the time once is a
reasonable and much-to-be-desired optimization.

Anywho, please consider changing the behavior of -newer such that it performs
the current behavior (check the time once) if and only if there are no -exec
arguments elsewhere in the predicate, and check the time every time if there
are -exec arguments elsewhere.  

Or, (ugh!) add either another time test predicate that checks every time (for
use with find | xargs constructions).




    _______________________________________________________

Carbon-Copy List:

CC Address                          | Comment
------------------------------------+-----------------------------
barry --AT-- dobyns --DOT-- com     | Originator Email




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=13212>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]