GitXplorerGitXplorer
g

sysexits

public
32 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
11eac5b8547f5dd2164aaa9e33363b1efecfdf50

Added tag v1.1.0 for changeset 2be7ed2d3669

gged committed 12 years ago
Unverified
f150d4eb19d22bb9377ada1934d7a0665f1b4a12

Added signature for changeset 2b88de1e7380

gged committed 12 years ago
Unverified
f1f707c6b4795db1cccf00f1c8d5c896684fb23d

Added tag semver for changeset d0f0419db01c

gged committed 12 years ago
Unverified
42ece0c6f3d57419bfc0a1f660d2a9dd1e577682

Update docs, add exit!.

gged committed 12 years ago
Unverified
1726bb2e520efa2fc64e5bdfcc37090b0a78703d

Added tag v1.0.2 for changeset d0f0419db01c

gged committed 14 years ago
Unverified
6965a4fd70fddcf9b11392522b514e722befccf4

Added signature for changeset 2baa1e0251b7

gged committed 14 years ago

README

The README file for this repository.

= sysexits

project:: https://bitbucket.org/ged/sysexits github:: https://github.com/ged/sysexits docs:: http://deveiate.org/code/sysexits

== Description

Have you ever wanted to call exit() 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 sysexits(3). Much to my chagrin, I couldn't find a +sysexits+ for Ruby! Well, for the other 2 people that actually care about style(9) 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, exit(1) 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 Sysexits::EX__BASE (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 include Sysexits, or as Sysexits::STATUS_CODES, 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 building a totally-awesome future in the Cloud™!

include Sysexits
exit EX_UNAVAILABLE

Okay, at least this is readable to people who have used fork() more than twice, but you could do so much better!

include Sysexits
exit :unavailable

Holy Toledo! It's like we're writing Ruby, but our own made-up dialect in which variable++ is possible! Well, okay, it's not quite that cool. But it does look more Rubyish. And no monkeys were patched in the filming of this episode! All the simpletons still exiting with icky numbers can still continue blithely along, none the wiser.

== Caveats

At some point, Apple started including their own +sysexits+ library in +vendor_ruby+, so to load the gem version on a MacOS X 10.7+ box, you need to do:

gem 'sysexits'
require 'sysexits'

It's a bit ugly, but there isn't a whole lot I can do about it. Sorry.

== Contributing

You can clone the source with Mercurial, submit bug reports, suggestions, etc., via the project page:

https://bitbucket.org/ged/sysexits

Or if you prefer Git, you can clone the source via its Github mirror:

https://github.com/ged/sysexits

After checking out the source, run:

$ rake newb

This task will install any missing dependencies, run the tests/specs, and generate the RDoc.

You can read more super-exited pointless marketing at:

http://deveiate.org/sysexits.html

Or maybe not.

== License

Copyright (c) 2010-2012, Michael Granger All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the author/s, nor the names of the project's contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.