Calling cygpath from find exec?
Eric Blake
eblake@redhat.com
Mon Nov 23 22:31:00 GMT 2015
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20151123/0f9f18ba/attachment.sig>
More information about the Cygwin
mailing list