find -execdir executes in wrong dir

Mon Nov 29 12:59:00 GMT 2010

I was wondering how a fix for the below can be obtained as soon as
it's available? The current implementation of find's -execdir has all
our scripts that use cygwin halted.


On Nov 22 13:13, Dirk Fassbender wrote:
> The behaviour of find -execdir is documented in the info pages.
> From the info page:
>  -- Action: -execdir command ;
>      Execute COMMAND; true if zero status is returned.  `find' takes
>      all arguments after `-execdir' to be part of the command until an
>      argument consisting of `;' is reached.  It replaces the string
>      `{}' by the current file name being processed everywhere it occurs
>      in the command.  Both of these constructions need to be escaped
>      (with a `\') or quoted to protect them from expansion by the
>      shell.  The command is executed in the directory in which `find'
>      was run.
> So
>     C:\cygwin\bin\find . -name file.txt -type f -execdir pwd ';'
> execute the "pwd" in the current directory and do not change directories.

The man page claims something different, or the wording in the info
file is ambiguous:

  -execdir command ;

  -execdir command {} +
	Like  -exec, but the specified command is run from the subdirecâ
	tory containing the matched file,  which  is  not  normally  the
	directory  in  which  you started find.  This a much more secure
	method for invoking commands, [etc]

Here's what happens with find 3.5.8:

  $ find . -name foobar -execdir pwd \; -execdir echo '{}' \;

And here what happens with find 3.5.9:

  $ find . -name foobar -execdir pwd \; -execdir echo '{}' \;


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list