Categories: CLI Utilities [Edit]
sysexits
Have you ever wanted to call <code>exit()</code> with an error condition, but
weren't sure what exit status to use? No? Maybe it's just me, then.
Anyway, I was reading manpages late one evening before retiring to bed in my
palatial estate in rural Oregon, and I stumbled across
<code>sysexits(3)</code>. Much to my chagrin, I couldn't find a +sysexits+ for
Ruby! Well, for the other 2 people that actually care about
<code>style(9)</code> as it applies to Ruby code, now there is one!
Sysexits is a *completely* *awesome* collection of human-readable constants for
the standard (BSDish) exit codes, used as arguments to +exit+ to
indicate a specific error condition to the parent process.
It's so fantastically fabulous that you'll want to fork it right away to avoid
being thought of as that guy that's still using Webrick for his blog. I mean,
<code>exit(1)</code> is so passé! This is like the 14-point font of Systems
Programming.
Like the C header file from which this was derived (I mean forked, naturally),
error numbers begin at <code>Sysexits::EX__BASE</code> (which is way more cool
than plain old +64+) to reduce the possibility of clashing with other exit
statuses that other programs may already return.
The codes are available in two forms: as constants which can be imported into
your own namespace via <code>include Sysexits</code>, or as
<code>Sysexits::STATUS_CODES</code>, a Hash keyed by Symbols derived from the
constant names.
Allow me to demonstrate. First, the old way:
exit( 69 )
Whaaa...? Is that a euphemism? What's going on? See how unattractive and...
well, 1970 that is? We're not changing vaccuum tubes here, people, we're
<em>building a totally-awesome future in the Cloud™!</em>
include Sysexits
exit EX_UNAVAILABLE
Okay, at least this is readable to people who have used <code>fork()</code>
more than twice, but you could do so much better!
include Sysexits
exit :unavailable...
Total
Ranking: 1,041 of 183,107
Downloads: 34,544,687
Daily
Ranking: 626 of 183,092
Downloads: 53,685
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|---|---|
1,010 | 36,349,053 | haml_lint |
10,284 | 229,396 | mongrel2 |
11,606 | 179,713 | inversion |
11,626 | 178,964 | strelka |
18,520 | 79,346 | usaidwat |
23,573 | 55,490 | symphony |
41,737 | 25,629 | statsdserver |
64,289 | 14,323 | projecter |
85,344 | 9,301 | artifactory-cleaner |
132,732 | 4,184 | treequel-shell |
133,719 | 4,133 | cli_ui |
134,846 | 4,078 | rub |
Depends on
Rank | Downloads | Name |
---|---|---|
25 | 817,849,894 | rspec |
99 | 348,223,614 | simplecov |
210 | 167,990,555 | rdoc |
2,086 | 8,574,300 | hoe |
22,685 | 58,649 | hoe-mercurial |
30,002 | 39,508 | hoe-highline |