This is the mail archive of the
mailing list for the Cygwin project.
Re: Inconsistency in find ... -name ...
- From: ericblake at comcast dot net (Eric Blake)
- To: Andrew DeFaria <Andrew at DeFaria dot com>, cygwin at cygwin dot com
- Date: Tue, 16 May 2006 11:37:20 +0000
- Subject: Re: Inconsistency in find ... -name ...
> > And notice that since there are no .h files in the current
> > directory, the shell passes the glob through unchanged
> > to find. You can also do 'shopt -s nullglob' to change that.
> I've wondered about this. Does bash special case the find command then?
> Which other commands does is special case like this?
The nullglob shell option just tells bash that if a glob does
not match any file name, remove the argument altogether
instead of passing the glob through as though it had been
quoted. Nothing about that is find-specific; although in
the case of 'find . -name *.pl', where there are no .pl files
in the current directory, with nullglob unset it finds *.pl files
in subdirectories, but with nullglob set, it is a syntax error.
Bash does not special case find, or any other command, unless
you write an alias or function in the environment to tell bash
how to special case it. See my previous email for an idea how
you use an alias (which is expanded prior to globbing, and hence
can temporarily supress globbing), combined with a function (the
alias can only work left-to-right, but by sticking a function in
the middle, you can use the function to rearrange when
things happen) in order to give find special treatment so
that you can use find with globbing supressed. And be aware
that my suggested alias is not perfect (think exit codes, among
other things); google will show you more complex examples
of the same idea. But none of it is cygwin specific, and by
default, bash globs everything that looks like a glob and
is not quoted, whether or not you intended for the glob
to be passed through literally.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html