X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-08.arcor-online.net 7CF38205A75 Message-ID: <4CEA5E6B.8070706@arcor.de> Date: Mon, 22 Nov 2010 13:13:31 +0100 From: Dirk Fassbender User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.12) Gecko/20101027 Lightning/1.0b2 Thunderbird/3.1.6 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: find -execdir executes in wrong dir References: <20101122111909 DOT GR18309 AT calimero DOT vinschen DOT de> In-Reply-To: <20101122111909.GR18309@calimero.vinschen.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Am 22.11.2010 12:19, schrieb Corinna Vinschen: > On Nov 21 05:02, pdanford wrote: >> I just upgraded to version 1.7.7-1 and the following find command is >> broken (which used to work correctly in a recent 1.7x version): >> >> C:\cygwin\bin\find . -name file.txt -type f -execdir pwd ';' >> >> Apparently, if there are say 10 matching file.txt files, -execdir >> executes the command in the first dir over and over. However, the >> following use of find works correctly: >> >> C:\cygwin\bin\find . -name file.txt -type f -execdir pwd '{}' + > It appears that this is a problem in find 3.5.9. > > I can reproduce this problem, even under Cygwin 1.7.5, and I examined > the strace output. What happens is that find forks for each call to > pwd. The forked find then calls fchdir before calling exec("pwd"). > > And here's the problem. Each single fchdir is called with the exact > same directory descriptor. There is an open file descriptor (fd 7) > which holds a handle to the *correct* directory, but the forked find > calls fchdir(4), which is a file descriptor holding the first directory > containing the file. > > This does not occur when using find 3.5.8. > > Eric? Would you mind to have a look? > > > Thanks, > Corinna > 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. Regards Dirk -- 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