[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grep: return code with -v and empty input
From: |
Alain Magloire |
Subject: |
Re: grep: return code with -v and empty input |
Date: |
Fri, 23 Mar 2001 14:43:52 -0500 (EST) |
>
> address@hidden (Edward Avis) writes:
>
> > According to the documentation, the -v flag is supposed to invert the
> > exit status:
> >
> > >Normally, exit status is 0 if matches were found, and 1 if no matches
> > >were found (the `-v' option inverts the sense of the exit status).
>
> > However it doesn't seem to work like that for empty input.
>
> > I suspect this may be a documentation bug; perhaps it should say
> > something like:
> >
> > 'If the -v flag is given, then a "matching line" is one which does _not_
> > match the pattern. The exit status is still 0 if there were no
> > "matching lines" and 1 if there were some.'
>
> That is indeed the way it is supposed to work according to POSIX.2:
>
> "
> -v Select lines not matching any of the specified patterns.
> ...
>
> The grep utility shall exit with one of the following values:
>
> 0 One or more lines were selected.
>
> 1 No lines were selected.
>
> >1 An error occurred.
> "
>
> Clarifying the documentation might be in order.
grep.info and man page:
Diagnostics
***********
Normally, exit status is 0 if selected lines are found and 1
otherwise. But the exit status is 2 if an error occurred, unless the
`-q' or `--quiet' or `--silent' option is used and a selected line is
found.
Is this not clear?
--
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!