On 30.05.2012 17:38, Robert Goldman wrote:
> Would it be a reasonable extension to reserve exit status 1 for "no
> plan" and catch other errors and set exit status 2 (or possibly vice
> versa, if other bits are likely to cause exit status to flow through)?
>
> I ask because I am not sure how to revise my shell script to distinguish
> these cases. I suppose I can check for an empty standard error, but as
> a wrapper that seems more brittle than catching an exit code....
Our current convention, which I don't think we follow strictly yet, is 2
for usage error (i.e., bad command-line syntax) and 1 for all other
kinds of errors including "no plan found". I'm not sure if "no plan
found", in a case where the algorithm proves that no plan exists, should
give a non-zero exit code at all. In any case it should definitely be
distinguished from actual errors in terms of exit code. My preferred
suggestion, if this should give a nonzero exit code at all, would be:
1 - no plan found
2 - usage error
3 - everything else (maybe distinguish these further)
Maybe we should also distinguish "no plan found and we proved that none
exists" from "no plan found, but the used algorithm was incomplete". Not
sure. (Certainly we don't currently have the necessary introspection
features to find out which of the two cases applies.)
But independently of this, what happens on out-of-memory conditions is
currently up the OS. The planner doesn't currently catch failed memory
allocation at all, so there is no explicit setting of an exit code that
we could change. So whatever outside behaviour you see is not
(currently) under the control of our code.
It would be a good idea to change this, of course, along with unifying
the exit codes. Unfortunately it's one of a thousand things that we
ought to do, so not sure if we can get to it any time soon (or at all).
:-( But if you want to move this forward, the first step would be to
open an issue in the tracker (of type "wish").
Cheers,
Malte