bug-grep
[Top][All Lists]
Advanced

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

bug#41700: grep -v always exiting with 1 for empty file


From: Norihiro Tanaka
Subject: bug#41700: grep -v always exiting with 1 for empty file
Date: Thu, 04 Jun 2020 19:26:34 +0900

On Wed, 3 Jun 2020 20:26:41 -0700
Andi Kleen <andi@firstfloor.org> wrote:

> 
> % grep --version
> grep (GNU grep) 3.4
> ...
> % echo -n > foo
> % grep -v foo foo ; echo $?
> 1
> 
> Would expect it to exit with zero in this case, since foo is not in the
> file.
> 
> When the file is one byte it works as expected:
> 
> % echo > foo
> % grep -v foo foo ; echo $?
> 
> 0
> %

`0 if a line is selected, 1 if no lines were selected,' in manual.
`0: One or more lines were selected. 1: No lines were selected.' in
POSIX.

> % echo -n > foo
> % grep -v foo foo ; echo $?

It returns no lines, so it seems reasonable to return 1.






reply via email to

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