Created
June 14, 2015 19:05
-
-
Save jackwillis/c7d78a52cf697cda6e8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Better Kernel::system in Ruby | |
def sys(cmd) | |
*resp, status = `#{cmd}; echo -n "\n$?"`.lines | |
[resp.join.chomp, status.to_i] | |
end | |
sys("echo foo") #=> ["foo\n", 0] | |
sys("echo -n foo") #=> ["foo", 0] | |
sys("false") #=> ["", 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment