It’s been a while since my last Ruby rant, but I have another one that I have to take off my shoulders. This time is the lack of a standard approach to run a system command and grab it exit status. Simple, right? Not in Ruby, while Ruby provides an API to interact with the shell as part of the standard library, it is absolutely mind boggling how horribly undocumented the shell standard library is. (See http://www.ruby-doc.org/stdlib-1.9.3/libdoc/shell/rdoc/Shell.html). I also looked into other Ruby modules like Open3, and it still didn’t offered the capability of easily grabbing the exit status of a shell command.
A couple of StackOverflow searches later, I found a really old gem called POpen4 that luckaly solves this problem. http://popen4.rubyforge.org/. I don’t want to live in a fantasy world, but it maybe nice to a method in Ruby that will run a system command and grab its exit status (along with stdout and sterr of course), without having to resort to an outside gem. As a Rubyists for a number of years now, this is really frustuating given that in other languages this can be easily accomplished, hence Python 3’s subprocess’ getstatusoutput() and PHP’s exec() function.