GNU grep 2.12 changes behavior of recursion options, breaks existing scripts
bugs.debian.org
bugs.debian.org
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=c6e3ea6...
Change -r to follow only command-line symlinks, and by default to read only devices named on the command line. This is a simple way to get a more-useful behavior when searching random directories; the idea is to use 'find' if you want something fancy. -R acts as before and gets a new alias --dereference-recursive.
Personally I think breaking compatibility for this change was a poor decision.
http://git.savannah.gnu.org/cgit/grep.git/log/?qt=grep&q...
And clicking on it says 'No repositories found'. Anybody else have this problem?
http://repo.or.cz/w/grep.git/commit/c6e3ea61d9f08aa0128a0eb1...
(Yea for the "D" in DVCS.)
Also, the corresponding bug which has additional discussion:
https://lists.gnu.org/archive/html/bug-grep/2012-03/msg00028...
I don't get it, can someone explain? It also appears in the ML thread linked elsewhere, and I don't understand it there either. (I understand the reasons for the change in behaviour, just not this specific line.)
$ find -name '*.c' -type f -exec grep printf '{}' +Wouldn't it be better to atleast let -r behave like ever and change -R?
Anyone ever used -R here? :)
Solaris, HP-UX and OpenServer have not.
AIX is weird:
> -r Searches directories recursively. By default, links to directories are followed.
> -R Searches directories recursively. By default, links to directories are not followed.
Hence, only lubutu's comment ("-R is the recursion flag for ls, cp, rm, etc") is true, while _delirium ("-R is the POSIX-standard flag for recursive grep") is wrong, which means AIX is free to do whatever it wants with both the -r and the -R flags.
I don't think distros should be afraid to break compatibility with main if main is making a change that makes no sense. Breaking essential and classic *nix functions defeats the purpose of CLI utilities.
Hi, I don't agree. Different versions of a tool showing different behaviour for the same option is enough for me; the same version of the tool showing different behaviour for the same option _depending on the distribution_ ... I feel that's too much!
It's going to be hard enough switching between a machine that only gets critical updates and a machine with the same distro but getting all updates. Grep has been around since 1973, is there any serious Unix scripter who feels it still needs more features?
New features should get new options; they should not move old features to new flags and put the new features on the old flags. Nuts.
But I started using -R today, in the middle of a WTF event while inspecting some Python files, digging up a Debian bug report, inspecting the upstream change and posting this to HN.
I still think it's not the best idea for Debian (or any other system) to break compatibility with upstream, since this will lead to different behaviors on different systems, not only depending on version and vendor (GNU or *BSD). But of course, it could also lead to the change being reverted, which would be welcome (guess nobody relies on the new behavior yet).
The POSIX argument is definitely valid, but nevertheless GNU's grep has always supported -r and BSD versions do as well (although OpenBSD's man page reads "This implementation supports those options; however, their use is strongly discouraged."), so it just unnecessarily breaks existing stuff.
/me updates rgrep alias to use -R
Not to say that this is a good or bad change.
-R matches the -R in chown/chgrp
They should really introduce -r for those two to NOT follow symlinks. Following symlinks for those is bad.
Edit: Come on. Downvotes for this? Honestly... It's HN, not StackOverflow. You don't mark questions as "off-topic" unless they're trolling...
grep is defined for POSIX after all: http://pubs.opengroup.org/onlinepubs/009695399/utilities/gre...
I also suspect (without looking) that there are obscure (but occasionally useful) grep features that ack doesn't support.
Edit: MattJ100 made a more clear point while I was responding.
The other points are quite understandable and correct though. It's always best to at least be familiar with standard tools, even if you want to use an slightly different version for yourself.
One example of a useful feature of grep: "grep --line-buffered" to grep with no buffering in a pipeline.
First time I've heard of it. Thanks. Only been grepping my way around for the last dozen years or so ...
"ACK is a highly versatile Kanji code converter. ACK can do reciprocal conversion among Japanese EUC"
This is probably why I don't use ack - never heard of it, not available on any system I use, and the dpkg repository has something that has nothing to do with grep.
Enough of an answer?
1. Because all the cool kids are doing it.
2. Because I hate Perl.
I think it's a bit sad that those "big-picture" features in unix are treated as if the were written in stone.
grep -in **/*txt "sometext"This feels a lot more like a "color of the bike shed" choice. There are use cases where the new behavior makes sense, sure, but there are also plenty of cases where the old way is better. This isn't an upgrade, it's a lateral move.
You basically imply that this change is not big enough to warrant a break with backwards compatibility, but small discontinuities and hacks add up. If thinks like this aren't fixed every once in a while the system will be ridden with inconsistencies.
Besides, even though it hurts when you've inherited some crazy unreadable code that utilizes some obsoleted functionality I think it is always positive for the code quality when the chaos monkey comes around and breaks something.
edit: the downvote button is to indicate I am detrimental to the discussion, the reply button is for when you disagree with me :)
seconded
What I do not understand is why (so it feels) recently, a lot of disagreement is done via the downvote, if someone actually just rationally states his/her opinion.
So back to topic...
This changes breaks rgrep, thus it should be held until a full version (3.0).
edit: my FreeBSD's `grep` manpage:
-R, -r, --recursive
Read all files under each directory, recursively; this is equiv-
alent to the -d recurse option.I absolutely agree than any changes to interface like this should be in clearly defined milestone releases, possibly allowing patches to be backported to legacy versions.
And yes, we have to continue with an ugly bikeshed for the rest of eternity, because a) beauty is highly subjective, and b) the color of the bikeshed is less important than breaking existing software on billions of computers worldwide.
It's not acceptable to break the default way it works under any circumstances.