Thu 15 Mar 2012 09:58:15 PM UTC, comment #7:
I installed a patch for this, so that -r does not follow symlinks or read devices (but -R still does, for those who prefer this):
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=c6e3ea61d9f08aa0128a0eb13d31a2fbad376f99
So I'm closing the bug report as 'fixed'; if there's a problem with the solution, please let me know and we can reopen the bug.
|
Tue 03 Jan 2012 11:32:41 PM UTC, comment #6:
This would break compatibility, but distinguishing based on case would be a simple option: -r/-R. For example, grep in Heirloom seems to be doing that. Afaict, for grep 2.7 -R, -r, --recursive are all the same.
From Heirloom grep man:
|
Tue 16 Mar 2010 07:47:09 PM UTC, comment #5:
Any chance of an update? This would be really amazingly helpful.
For example, when trying to find a string which we know is in /etc/<somewhere>, it's sensible to grep through a few MB of stuff in /etc. Except that apache is often configured with symlinks from /etc/ to /lib
Similarly, when searching in /home, one might come across .wine/dosdevices/* which symlink back to /
And the grep then ends up taking an hour.
|
Wed 23 Dec 2009 07:55:25 AM UTC, comment #4:
What about --[no-]dereference-symlink-to-dir (can be shortened to --[no-]dereference since there's no ambiguous option)? cp's -H could become --dereference-symlink-to-dir=cmdline (using an optional argument).
-S can be used as a short option.
Karl's proposal to have --directories=recurse-no-symlink is a bit ugly because there is no quick way to specify it as a short option.
|
Tue 22 Dec 2009 10:18:19 PM UTC, comment #3:
Use the same option name as in coreutils?
--dereference-command-line-symlink-to-dir
And FWIW, personally I'd be happy if --dereference-command-line-symlink-to-dir became the new default (even me, Mr. Backward Compatibility Rules :). I suspect that's what users really want/expect 99% of the time.
Having these things as option values for --directories sounds reasonable, given that we are talking about following symlinks to dirs, not files (right?).
|
Tue 22 Dec 2009 08:31:02 PM UTC, comment #2:
Hi Paolo,
I too have long wished for a way to make grep -R not follow symlinks.
My first thought was to handle it like find, cp, du, ls and chown etc.
have done, with their -H, -L and -P options, but all of those are already
in use with grep.
One approach would be to extend
--directories=...
or some new long-option to accept three new values,
corresponding to these (useful only with --recursive, which is
equivalent to --directory=recurse, or perhaps implying that):
H traverse-command-line-symlink-to-dir
L traverse-every-symlink-to-dir
P traverse-no-symlink-to-dir
|
Tue 22 Dec 2009 09:12:32 AM UTC, comment #1:
> grep -R follows symbolic links, unlike cp or ls.
> At least, one option should be provided to disable this behaviour.
Jim, do you have an opinion on this? I'm inclined to mark it as invalid or at least as an enhancement, but you're the expert on these things. :-)
|
Wed 06 Sep 2006 07:09:24 AM UTC, original submission:
grep -R follows symbolic links, unlike cp or ls.
At least, one option should be provided to disable
this behaviour.
|