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: [EMAIL PROTECTED] 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/ _______________________________________________ Bug-findutils mailing list Bug-findutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-findutils