X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_05,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org MIME-Version: 1.0 Date: Mon, 29 Nov 2010 07:11:44 -0500 Message-ID: Subject: Re: find -execdir executes in wrong dir From: pdanford To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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. Thanks, Peter - www.pdanford.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=E2 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 --=20 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