grep is always recursive

Smoot Carl-Mitchell smoot at tic.com
Tue Jan 27 21:30:40 UTC 2009


On Tue, 2009-01-27 at 17:45 -0300, Lorenzo Luengo wrote:

> The problem comes from the bash * expansion that makes grep see that 
> filename as an option. Is it a bash problem? Is it a grep problem?? 
> Don't know...
> 
> Should it be reported to anyone?

The root of the problem is the getopt function in the C library which is
the standard way of doing option processing in C programs.

The glob shell expansion of '*' is correct.  There is nothing but
convention that restricts filenames from beginning with "-". I suppose a
workaround to the '*' expansion is to do something like:

grep foo -- *

I suppose this could be filed as a bug, but I doubt it will be given a
real high priority.
-- 
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list