Thu 30 Sep 2004 09:29:07 AM UTC, comment #2:
The proposed solution is not right.
-r alias alias -R --recurse is equivalent to --directories=recurse.
Any of these forms can be used in env. var GREP_OPTIONS.
If -r (or an equivalent) is set in GREP_OPTIONS, it's not a mistake when grep is then run without parameters.
One possibility would be to distinguinsh whether the option was given on cmdline or via GREP_OPTIONS. But I don't think it's the right solution.
And what if someone defines an alias for ``grep --directories=recurse''? That seems natural, doesn't it?
I think it would have been better if -r wasn't defined as
an equivalent for --directories=recurse. -r should have been defined to imply --directories=recurse and something more. That ``something more'' could have been your warning, or it could have been that the default is ``.'' (current dir), not stdin.
My current opinion is that future versions of grep should have an option, say --default-to-curdir, which would be defined as follows:
when this oprion is on, -r, -R, and --recurse not only imply --directories=recurse, but also immply that when no parameters are given, grep searches recursively the current directory.
Anyone could then put
GREP_OPTIONS=--default-to-curdir; export GREP_OPTIONS
to his .profile.
I also contemplated breaking the backward compatibility and implementing this permanently, but it's probably not worth it.
Hope you'll like this solution.
|