It has two pipes; got tickets to the show?
Switch branches/tags
Nothing to show
Latest commit 38c78ee Nov 9, 2009 @bmizerany v0.1.4
Failed to load latest commit information.
lib rich error Nov 9, 2009
.gitignore ignore gems Nov 5, 2009 last, but not least Nov 5, 2009
guns.gemspec v0.1.4 Nov 9, 2009


It has two pipes; got tickets to the show?

A low overhead sh utility to replace session


gem install guns -s


DISCLAIMER: It's not recommended to use guns in place of you shell I'm purely using IRB for demonstration

$ irb -r rubygems -r guns
>> "ls not-a-dir"
=> ["", "ls: not-a-dir: No such file or directory\n", 1]

The sh method returns a tuple containing stdout, stderr, and exitstatus.

Die hard

>>! "ls not-a-dir"
Guns::Failure: ls: not-a-dir: No such file or directory

    from ./lib/guns.rb:50:in `sh!'
    from (irb):3

sh! will raise an error on a non-zero exit status

Environment variables

>> "echo $FOO", "FOO" => "bar"
["bar\n", "", 0]

Further Reading

If you need more flexability and features, see Rush

TODO: Replace popen3


Joe Ruscio for helping me debug that nasty deadlock

Ryan Tomayko for Shotgun; where I got started with this

Adam Wiggins for Rush