On 07/07/12 09:51, quoting Erwin Waterlander, Eli Zaretskii wrote:
>> Okay, with escaping it works. But I think that escaping and quoting
>> is a hassle for an average windows user.
What? You mean the average Windows user who litters path and file names
with embedded white space, making quoting mandatory?
> ?? But you are _supposed_ to quote wildcards where you need 'find' to
> get them unexpanded.
Exactly so.
>> And for the 'find' command I see no use for the globbing.
>
> There are valid use cases when you'd want globbing. Here's a trivial
> example:
>
> find *.c -exec fgrep FOOBAR "{}" ";"
Obviously a contrived example, since
fgrep FOOBAR *.c
should deliver a similar (perhaps more useful) result, with rather more
natural usage. Interestingly, although it will work, (I checked), in
20+ years of running and administering *nix systems, I don't think I've
ever considered using a globbing pattern which I'd expect to generate a
list of *file* names, (rather than directory path names), for the search
location in a find command.
>> Globbing makes 'find' fail when the argument matches files in the
>> current directory.
As it *should*...
> With unquoted wildcards, and in arguments to -name etc., yes. That's
> why you need to quote them.
>
>> I continue with Eli's port of findutils.
>
> Which already disables globbing where it is not needed, but still does
> glob in arguments where you'd want that. E.g., the above trivial
> example should work with my port.
Perhaps I'm misunderstanding here: are you saying that this real world
example, (which I might use to clean up a Mercurial tree after doing an
'hg revert', when I finally want to abandon the reverted changes):
find -name "*.orig" -exec rm {} +
*wouldn't* glob the "*.orig" argument, if I neglected to quote it? If
so, that seems a rather dangerous precedent to set -- better to keep the
behaviour consistent with *nix, or MSYS bash, IMO. But perhaps I'm just
reading too much between the lines, and all you really mean is that
you've circumvented the entirely inappropriate globbing *inside* quotes,
(as recent MSVCRT.DLL seems to insist on doing)? If the latter is
indeed the case, then apologies for the noise; this is definitely the
right thing to do.
--
Regards,
Keith.
|