[Top][All Lists]

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

[bug #17782] unwanted prefix "./" before arguments when using -execdir w

From: Andreas Metzler
Subject: [bug #17782] unwanted prefix "./" before arguments when using -execdir with find
Date: Sun, 17 Sep 2006 12:51:46 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060904 Debian/1.7.8-1sarge7.2.2


                 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



This http://bugs.debian.org/385896 reported by WANG Yunfeng.

Short version
address@hidden:/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
$ find / -maxdepth 1 -wholename / -execdir pwd \;
$ 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:


  Nachricht geschickt von/durch Savannah

reply via email to

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