bug-grep
[Top][All Lists]
Advanced

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

Re: grep . /; echo $?


From: Aharon Robbins
Subject: Re: grep . /; echo $?
Date: Wed, 09 Nov 2005 21:12:52 +0200

> Date: Fri, 04 Nov 2005 16:53:03 -0500
> From: Charles Levert <address@hidden>
> Subject: Re: grep . /; echo $?
> To: address@hidden
>
> .....    This would go well with
> my proposal to track the kind of error (i.e.,
> which system call) with a bit-flag in the exit
> code as well.

My two cents: this isn't worth the trouble. I've written lots of shell scripts
in my life, and typically all one really wants to know is success/failure:

        if grep pattern file > /dev/null
        then
                ...
        else
                ...
        fi

Not to mention that extracting bits from the exit value in a shell script
is, shall we understate it, painful.

My suggestion is to K.I.S.S.:

EXIT CODE
        0 - found at least one match
        1 - found no matches at all
        2 - something went wrong

Arnold




reply via email to

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