URL: <http://savannah.gnu.org/bugs/?17782>
Summary: unwanted prefix "./" before arguments when using -execdir with find Project: findutils Submitted by: ametzler Submitted on: Sonntag 17.09.2006 um 12:51 Category: find Severity: 3 - Normal Item Group: None Status: None Privacy: Public Assigned to: None Originator Name: WANG Yunfeng Originator Email: Open/Closed: Open Release: 4.2.28 Fixed Release: None _______________________________________________________ Details: This http://bugs.debian.org/385896 reported by WANG Yunfeng. Short version Bug: [EMAIL PROTECTED]:/tmp/testingfind$ find -type f -execdir echo sh -c 'file -b {} | true' \; sh -c ./file -b d | true Expected output sh -c file -b ./d | true Complete original bugreport follows: --------------------------------------- When action "-execdir" was used with find, a string "./" was prepended to any argument containing replace pattern "{}", leading to this error: $ find -type f ! -name "*.gz" -execdir sh -c \ > 'file -b {} | grep -q "gzip compressed data" && mv {} {}.gz' \; sh: ./file: No such file or directory I've gone through codes related with this prefixing behavior in the source code of findutils, and found these relevant lines: line 509 in find/pred.c : const char *prefix = (state.rel_pathname[0] == '/') ? NULL : "./"; lines 278+ in lib/buildcmd.c : if (prefix) { strcpy (state->argbuf + state->cmd_argv_chars, prefix); state->cmd_argv_chars += pfxlen; } ... In most cases such design was not a bad idea since {} was generally placed alone, sometimes even quite good for dealing with unusual file names like "-l". But if we want to do some complex operations as shown above, this will turn to be a mess. Possible resolution could be discarding this feature since those who need prefix "./" can specify it explicitly at the beginning of argument; or at least a switch to turn off this behavior should be provided. Another possible bug concerning "-execdir" shown below: $ pwd /tmp $ find / -maxdepth 1 -wholename / -execdir pwd \; /tmp $ find / -maxdepth 1 -wholename /boot -execdir pwd \; / Among these two find invocations, the latter conforms to the description in find's manpage while the former does not. This inconsistency seems to occur only when the matching filename was "/". I'm not sure if this is another special handling or not. ps: action "-okdir" works basically the same way as "-execdir". ------------------------------- _______________________________________________________ Carbon-Copy List: CC Address | Comment ------------------------------------+----------------------------- Available only the item webpage | original bug submitter _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?17782> _______________________________________________ Nachricht geschickt von/durch Savannah http://savannah.gnu.org/ _______________________________________________ Bug-findutils mailing list Bug-findutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-findutils