grep is always recursive

Matthew Flaschen matthew.flaschen at
Wed Jan 28 05:08:15 UTC 2009

Cameron Hutchison wrote:
>> 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)
> It could be fixed in the shell, rather than getopt. If a wildcard
> expands to a filename starting with a -, prefix that with ./ .

Except the standard says, "The slash character in a pathname shall be
explicitly matched by using one or more slashes in the pattern; it shall
neither be matched by the asterisk or question-mark special characters
nor by a bracket expression"

In other words, * can not match a /.

If you want paths to start with ./, you need to put ./*

> This may break some esoteric scripts that do funny things with filename
> expansion, but if it is done in bash rather than sh, it could be done
> with an option to turn it off.

Bash should be backwards-compatible with sh by /default/.

Matt Flaschen

More information about the ubuntu-users mailing list