Re: exit status
David Goodger <[email protected]> Fri, 13 Jun 2003 10:27:03 -0400
| Newsgroups | gmane.comp.python.optik.user |
|---|---|
| Message-ID | <[email protected]> |
Greg Ward wrote:
> Got any more compelling source than that?
The bash manpage corroborates:
All builtins return an exit status of 2 to
indicate incorrect usage.
However, sysexits.h has EX_USAGE == 64. This is now exposed in Python
2.3's os.EX_USAGE.
> That said, if you feel a burning compulsion to make the change, go
> ahead.
Not burning, just a mild compulsion to adhere to standards when
relevant. In this case there appears to be an old informal standard
(exit status 2), and a new formal standard (EX_USAGE == 64) which
doesn't appear to be well-known or -used. So it's a toss-up.
> no matter how hard I try, I can't make myself like "print >>". ;-(
But you use it in OptionParser.print_usage and .print_version. ;-)
(For convenience, it appears.)
There's a slight difference in semantics with the change. If the
SystemExit exception is caught, no error message would be written wit
the original code:
sys.exit("%s: error: %s" % (get_prog_name(), msg))
But the error message would be written with the new code:
sys.stderr.write("%s: error: %s\n" % (get_prog_name(), msg))
sys.exit(2)
Very minor difference, and probably not significant.
-- David Goodger
-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5