This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Calling cygpath from find exec?


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).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]