From: Duncan Roe <duncan_roe@acslink.net.au>
To: cygwin@cygwin.com
Subject: Re: Calling cygpath from find exec?
Date: Tue, 01 Dec 2015 20:43:00 -0000 [thread overview]
Message-ID: <20151201204301.GB2707@dimstar.local.net> (raw)
In-Reply-To: <565383D5.3010709@redhat.com>
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
next prev parent reply other threads:[~2015-12-01 20:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-23 21:14 Matt D.
2015-11-23 21:16 ` Nellis, Kenneth
2015-11-23 22:31 ` Eric Blake
2015-12-01 20:43 ` Duncan Roe [this message]
2015-12-01 20:52 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151201204301.GB2707@dimstar.local.net \
--to=duncan_roe@acslink.net.au \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).