News for hackers. Stuff that matters.
Re:GNU grep 2.12 changes behavior of recursion options, brea... by buster on Thursday July 26, 2012 @09:27AM (#4295831)
Who thought it might be a good idea to break -r (most likely the most often used option) and use the old behaviour for -R?

Wouldn't it be better to atleast let -r behave like ever and change -R?

Anyone ever used -R here? :)

Re:GNU grep 2.12 changes behavior of recursion options, brea... by _delirium on Thursday July 26, 2012 @10:15AM (#4296043)
-R is the POSIX-standard flag for recursive grep, so that would be worse to change imo. It's also the flag used for recursive grep by the BSDs (some of which do support '-r', but only as a deprecated historical option... OpenBSD calls it "strongly discouraged").
Re:GNU grep 2.12 changes behavior of recursion options, brea... by eschulte on Thursday July 26, 2012 @10:51AM (#4296219)
Thanks for these important missing bits of information, in light of these I think the change sounds much more reasonable.

/me updates rgrep alias to use -R

Re:GNU grep 2.12 changes behavior of recursion options, brea... by ineedtosleep on Thursday July 26, 2012 @12:45PM (#4296967)
Currently -r and -R are essentially the same flags, correct? And this new change would make -R and -r two different operations?
Re:GNU grep 2.12 changes behavior of recursion options, brea... by 0x0 on Thursday July 26, 2012 @09:40AM (#4295886)
Yeah, this sounds really misguided. If they change/add functionality, why not move that to a new option? Those who want the new way can use the new feature, and scripts won't act differently depending on which version is installed.

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.

Re:GNU grep 2.12 changes behavior of recursion options, brea... by rmc on Thursday July 26, 2012 @10:10AM (#4296027)
Increasing the number of options and switches has downsides, it makes the software more complex to use.
Re:GNU grep 2.12 changes behavior of recursion options, brea... by 0x0 on Thursday July 26, 2012 @10:28AM (#4296101)
Hehe, you know what makes the software more complex to use? Having to grep in the output of "grep --version" before deciding which switch to pass to grep.. :)
Re:GNU grep 2.12 changes behavior of recursion options, brea... by michaelhoffman on Thursday July 26, 2012 @10:35AM (#4296128)
You don't need to do that, just always use -R :)
Re:GNU grep 2.12 changes behavior of recursion options, brea... by nitrogen on Thursday July 26, 2012 @05:02PM (#4298712)
We'll get right on inventing that time machine so everyone can go back in time to the introduction of the -r flag and warn themselves ;).
Re:GNU grep 2.12 changes behavior of recursion options, brea... by rbanffy on Thursday July 26, 2012 @05:26PM (#4298830)
And note that it will make your code more compatible with other, POSIX-compliant, versions of grep.
Re:GNU grep 2.12 changes behavior of recursion options, brea... by freehunter on Thursday July 26, 2012 @09:37AM (#4295873)
When I read the first post in the chain, I thought "well, it has to be a bug". Then I read the second post... wow, it was intentional. I've used -r and -R both in the same script to do the same thing, just depending on how I was feeling that day. Now I'm afraid to update.

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.

Re:GNU grep 2.12 changes behavior of recursion options, brea... by pif on Thursday July 26, 2012 @12:18PM (#4296783)
> I don't think distros should be afraid to break compatibility with main if main is making a change that makes no sense.

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!

Re:GNU grep 2.12 changes behavior of recursion options, brea... by freehunter on Thursday July 26, 2012 @01:23PM (#4297295)
Well, like the link states this already breaks compatibility with BSD grep. Combine that with breaking compatibility with previous version, breaking previous scripts, and breaking based on distro depending on the speed at which the package maintainers upgrade (if ever)... it's best IMO to just leave it the way it always was.

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?

Re:GNU grep 2.12 changes behavior of recursion options, brea... by leif on Thursday July 26, 2012 @09:33AM (#4295851)
Yeah, for habitual reasons I usually use -R. No idea why.
Re:GNU grep 2.12 changes behavior of recursion options, brea... by lubutu on Thursday July 26, 2012 @09:45AM (#4295905)
In POSIX -R is the recursion flag for ls, cp, rm, etc. So if you want to recurse, -R is probably a safer bet than -r. (ls -r just lists in reverse.)
Re:GNU grep 2.12 changes behavior of recursion options, brea... by buster on Thursday July 26, 2012 @09:53AM (#4295939)
Yeah, that may be it.. I'm wondering why they didn't just add a new option (aka --no-symlinks) or something
Re:GNU grep 2.12 changes behavior of recursion options, brea... by a3_nm on Thursday July 26, 2012 @02:23PM (#4297720)
Annoying exception: scp only accepts -r as recursion flag, not -R.
Re:GNU grep 2.12 changes behavior of recursion options, brea... by wildmXranat on Thursday July 26, 2012 @10:09AM (#4296020)
Same here. I've been conditioned to use -R
Re:GNU grep 2.12 changes behavior of recursion options, brea... by mturmon on Thursday July 26, 2012 @04:53PM (#4298660)
Good point. Also, since you reminded me, chmod, chown, chgrp.
Re:GNU grep 2.12 changes behavior of recursion options, brea... by leif on Thursday July 26, 2012 @09:48AM (#4295919)
that's probably it
Re:GNU grep 2.12 changes behavior of recursion options, brea... by adavies42 on Thursday July 26, 2012 @11:34AM (#4296507)
ever work on a non-gnu box? (old solaris, *bsd, stock os x, etc.) there's a decent chance they don't have -r at all.
Re:GNU grep 2.12 changes behavior of recursion options, brea... by cschramm on Thursday July 26, 2012 @11:43AM (#4296566)
*BSDs have (=> OS X probably too).

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.

Re:GNU grep 2.12 changes behavior of recursion options, brea... by rbanffy on Thursday July 26, 2012 @05:27PM (#4298836)
Isn't the AIX behavior the one POSIX specifies?
Re:GNU grep 2.12 changes behavior of recursion options, brea... by cschramm on Friday July 27, 2012 @12:27AM (#4300018)
Looking at MattJ100's link (http://pubs.opengroup.org/onlinepubs/009695399/utilities/gre...), it seems like POSIX grep actually does not have any recursion.

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.

Re:GNU grep 2.12 changes behavior of recursion options, brea... by lmm on Thursday July 26, 2012 @06:04PM (#4298994)
That would be kind of perverse given how cp behaves for -r and -R
Re:GNU grep 2.12 changes behavior of recursion options, brea... by cschramm on Thursday July 26, 2012 @10:04AM (#4295994)
I've always used -r before, since it saves a key press. ;)

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.

Re:GNU grep 2.12 changes behavior of recursion options, brea... by emmelaich on Friday July 27, 2012 @12:40AM (#4300054)
I've only used -R, because of it's posixness. Finger memory from adminning Solaris.

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.

Re:GNU grep 2.12 changes behavior of recursion options, brea... by jasomill on Thursday July 26, 2012 @02:45PM (#4297866)
I've always use -R, presumably because it's consistent with other commands like ls, rm, and cp (and consequently get annoyed by tools like scp that only support -r, and zip, that use -R for something else entirely); I wasn't even aware that -r was supported until I saw this.