X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=QYzw RqRWaltxITu0F1hvN3JDyN4WUX4PBdMOB3Hgm7FwRp3xgajPBFnG1FU5suClYKMf 10UHjrbqcUV6VHpsyrUqOXY9C/z+KZsEn0iqMq395K6GqB8XpUiHc7WfRwgv+0JH GUPSdfcP6QbdUysOzsNH4j71IuqaC9YocBa3GBw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=69a6Msn9u3 ToKMTEyMmthmAnjWs=; b=p+4YlPv0HTsYxqw9EV/Z4fujfoCbaySh+NqX6FYUP6 MF8/jfIpGwgYgIXY0RoRODwBNxaUAUXBVyARmclNnFubLPpW0VkEAy+BvLqiDkT+ XHg6CfjbNOg5//6NUxq7qJBviKgD6Cv/1tGMCq13dUdwZJqhuLpy9oShWClwiqTW c= 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 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 Date: Wed, 2 Dec 2015 07:43:01 +1100 From: Duncan Roe To: cygwin AT cygwin DOT com Subject: Re: Calling cygpath from find exec? Message-ID: <20151201204301.GB2707@dimstar.local.net> Mail-Followup-To: cygwin AT cygwin DOT com References: <56537B03 DOT 4050204 AT codespunk DOT com> <565383D5 DOT 3010709 AT redhat DOT 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 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