bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#454690: "grep -v" alway returns 0 (was: sl-modem-source: Modules


From: Eduard Bloch
Subject: Re: Bug#454690: "grep -v" alway returns 0 (was: sl-modem-source: Modules don't load)
Date: Sun, 29 Mar 2009 14:24:13 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

#include <hallo.h>
* Aníbal Monsalve Salazar [Sun, Mar 29 2009, 02:59:37PM]:
> retiltle 454690 "grep -v" alway returns 0
> thanks
> 
> On Thu, Dec 13, 2007 at 10:11:41PM +0100, Eduard Bloch wrote:
> >reassign 454690 grep
> >thanks
> >
> >#include <hallo.h>
> >* Eduard Bloch [Thu, Dec 13 2007, 08:41:41PM]:
> >>#include <hallo.h>
> >
> >>... found it and tried to load...
> >>
> >>> + grep -v not.found
> >>
> >>... detected "not found" in the modprobe output...
> >
> >Wait a sec, I see the problem. The current "grep -v" apparently always
> >returns 0, no matter whether the expression matched something or not.
> >It worked with earlier versions though, i.e. non-zero was returned if
> >the expression matched at least once (and so some output was
> >supressed).
> >
> >I will work around the issue in sl-modem-daemon ASAP but it remains a
> >problem in grep.
> >
> >Regards,
> >Eduard.
> >-- 
> ><LGS> Halloechen, ihr Spinner, so frueh auf?
> ><nusse> nein, wir schlafen alle im kollektiv
> ><knorke> mein alkoven ist kaputt
> ><teq> alkohol kaputt?
> 
> I can reproduce this bug.
> 
> grep -V
> GNU grep 2.5.4
> 
> echo -e 'hola\nhello' | grep -v hola; echo $?
> hello
> 0
> 
> echo -e 'hola\nhello' | grep -v hallo; echo $?
> hola
> hello
> 0

And what's the point of your test?

$ echo -e 'blub\nbla'  | grep -v blub ; echo $?
bla
0
$ echo -e 'blub'  | grep -v blub ; echo $?
1
$ echo -e 'bla\nblub'  | grep -v blub ; echo $?
bla
0

What's the meaning of the exit status? Manpage talks about "selected
lines". What does this mean with -v? What does "selection" mean? The -v
pattern is matched, is this "selected"? Intuitive answer: yes. But it
seems that "selected" refers to the rest, i.e. NOT matched lines in
this case.

The problem is, if you don't know for sure, you have to try it out
untill you hope to know. And even than it can be misleading:

$ echo -n | grep -vq bla ; echo $?
1
$ echo -e | grep -vq bla ; echo $?
0

Regards,
Eduard.

-- 
Salz has changed the topic on channel #debian.de to FAQ: channel.debian.net
        [ Heute: Manpages vorgelesen ]
<Fuchur> Vielleicht sollte man aus den man-Pages ein Hörbuch machen.
        Das ist doch gerade hip.  Alle man-Pages auf 172 CDs ...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]