bug-bash
[Top][All Lists]
Advanced

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

Re: failed grep should cause subshell to exit


From: Chris Down
Subject: Re: failed grep should cause subshell to exit
Date: Tue, 27 Aug 2013 03:48:16 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On 2013-08-26 21:41, David Lehmann wrote:
> I expected the '!' to reverse the exit code, such that if the grep return 0
> (success), the expression would return 1 (failure); if the grep returned
> non-zero (failure), the expression would return 0 (success).   i.e. I
> expected the '!' to behave like it does in C.

It does -- like Andreas said, it just makes it immune to `set -e'.

    $ set -e
    $ > file
    $ ! grep foo file
    $ echo $?
    0

Attachment: pgpvhebtVXrXu.pgp
Description: PGP signature


reply via email to

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