grep is always recursive
Derek Broughton
derek at pointerstop.ca
Wed Jan 28 03:19:51 UTC 2009
Matthew Flaschen wrote:
> Smoot Carl-Mitchell wrote:
>> 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.
>
> Given the way the shell does expansion, and the way arguments are passed
> to C programs, how would you design get opt to eliminate this problem?
> I don't think it's possible to "fix" this in getopt (which is not used
> by all C programs anyway)
You _could_ easily enough - you just say that the first non-option argument
terminates reading of options (just like -- does). I should think you could
even drop a modified getopt onto your system that does that.
Of course, there'd be howls from the geeks who've been using this for
decades. In fact, I'm mostly aware that not every program uses getopt only
because some $%^&*( programs insist I put the options before any other
arguments! I learned Unix when there was only one Unix, and I damn well put
my options where I feel like it!
More information about the ubuntu-users
mailing list