Subject: Re: a few minor cleanups to src/share/misc/style
To: Greywolf <>
From: Chris G. Demetriou <>
List: tech-userlevel
Date: 03/21/2001 23:34:43 (Greywolf) writes:
> On Wed, 21 Mar 2001, Greg A. Woods wrote:
> # Some failures aren't "random".  There are a few common classes of
> # errors, common enough that there are even de facto standards for exit
> # codes to represent them, the most common probably being usage errors
> # (with a corresponding exit value of 2).
> Usage error == 2?  Never in my life.
> Usage error falls under domain of "failed to functionally meet command-line
> criteria".

looking at the solaris grep manual page -- and you mentioned grep -- i

     2         Syntax  errors  or  inaccessible  files  (even  if
               matches were found).

syntax error in this case in fact means usage error:

47 [tremor] src % grep '[' /etc/passwd
grep: RE error 49: [ ] imbalance.
48 [tremor] src % !echo
echo $status

perhaps your description applies... but in fact it fails because the
user failed to supply a valid regexp.

The NetBSD (gnu) grep manual page says:

       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.)  Exit status is 2 if there were  syn-
       tax  errors  in  the pattern, inaccessible input files, or
       other system errors.

so in addition to file not found, and usage errors, you get "whims of
the system."  and that assumes that e.g. it wasn't _killed_ e.g. due
to out of swap, or a parity error that caused the process to die (not
done on NetBSD), or ...