From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108474 invoked by alias); 1 Dec 2015 20:43:12 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 108460 invoked by uid 89); 1 Dec 2015 20:43:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL,BAYES_40,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail110.syd.optusnet.com.au Received: from mail110.syd.optusnet.com.au (HELO mail110.syd.optusnet.com.au) (211.29.132.97) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Dec 2015 20:43:10 +0000 Received: from dimstar.local.net (c122-107-168-99.eburwd5.vic.optusnet.com.au [122.107.168.99]) by mail110.syd.optusnet.com.au (Postfix) with ESMTP id BDDBF781D15 for ; Wed, 2 Dec 2015 07:43:07 +1100 (AEDT) Received: (qmail 2821 invoked by uid 501); 1 Dec 2015 20:43:01 -0000 Date: Tue, 01 Dec 2015 20:43:00 -0000 From: Duncan Roe To: cygwin@cygwin.com Subject: Re: Calling cygpath from find exec? Message-ID: <20151201204301.GB2707@dimstar.local.net> Mail-Followup-To: cygwin@cygwin.com References: <56537B03.4050204@codespunk.com> <565383D5.3010709@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <565383D5.3010709@redhat.com> User-Agent: Mutt/1.5.22 (2013-10-16) X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=cK4dyQqN c=1 sm=1 tr=0 a=+cDhJlqnNvz9E7c5l3ERGg==:117 a=+cDhJlqnNvz9E7c5l3ERGg==:17 a=y26AOypDAAAA:8 a=PO7r1zJSAAAA:8 a=iaFubHWvAAAA:8 a=kj9zAlcOel0A:10 a=wUQvQvOEmiQA:10 a=tZ75DkMt9peIArJuMeAA:9 a=CjuIK1q_8ugA:10 X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00014.txt.bz2 On Mon, Nov 23, 2015 at 02:23:33PM -0700, Eric Blake wrote: > On 11/23/2015 01:45 PM, Matt D. wrote: > > Is there a reason why these produce different results? > > > > find . -exec cygpath -wa {} \; > > find . -exec echo $(cygpath -wa {}) \; > > Incorrect quoting. You are invoking: > > find . -exec echo c:\cygwin\home\you\{} \; > > (or whatever ./{} resolves to), instead of one cygpath per name found by > find. > > > > > I have to do this which is much slower: > > find . -exec bash -c 'echo $(cygpath -wa {})' \; > > > > This indeed quotes things so that cygpath is now invoked once per file, > but at the expense of an additional bash per file as well. > > Why not just: > > find . -exec cygpath -wa {} + > > since cygpath handles more than one file in an invocation (that is, > using '-exec {} +' rather than '-exec {} \;' is generally faster). > I would be using xargs. Especially under /cygdrive, the "-print0 / xargs -0" combination takes care of spaces and other nasties in file names. find . -print0 | xargs -0 cygpath -wa For utilities that only accept one argument, you can use xargs -n1 -0; you still get the benefit of -print0. Cheers ... Duncan. -- 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