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

Eric Blake

Unsubscribe info:
Problem reports:

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