| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-Spam-Check-By: | sourceware.org |
| Date: | Mon, 22 Nov 2010 13:37:05 +0100 |
| From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: find -execdir executes in wrong dir |
| Message-ID: | <20101122123705.GS18309@calimero.vinschen.de> |
| Reply-To: | cygwin AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| References: | <AANLkTi=QE=PSXVb5XUKhTLrbt+0gsaWMg_kvFYscRwQH AT mail DOT gmail DOT com> <20101122111909 DOT GR18309 AT calimero DOT vinschen DOT de> <4CEA5E6B DOT 8070706 AT arcor DOT de> |
| MIME-Version: | 1.0 |
| In-Reply-To: | <4CEA5E6B.8070706@arcor.de> |
| User-Agent: | Mutt/1.5.20 (2009-06-14) |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
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 '{}' \;
/home/corinna/tmp/abc
./foobar
/home/corinna/tmp/DOS
./foobar
/home/corinna/tmp/foo
./foobar
/home/corinna/tmp
./foobar
And here what happens with find 3.5.9:
$ find . -name foobar -execdir pwd \; -execdir echo '{}' \;
/home/corinna/tmp/abc
./foobar
/home/corinna/tmp/abc
./foobar
/home/corinna/tmp/abc
./foobar
/home/corinna/tmp/abc
./foobar
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |