I was annoyed with the fact that when you use Ruby backticks (i.e. `some_shell_command`) to shell out to an external program and the path to the program is wrong then no exception is raised. In addition, using system and backticks doesn't allow you to capture standard error. I decided to write a little plugin called shell that allows you to do things like this:
# Raise exception on failure:
status, output, error = Shell.run!("/opt/local/bin/curl http://example.com")
It turns out some commands will indicate success with an exit code of 0 but still write to standard error. I have put in a special case in the Shell class that treats "No such file or directory" as a failure eventhough we have a zero exit code in that case.
I'm curious to hear from if there is a simpler and more idiomatic way to do this. It seems odd that I have to write a Rails plugin to invoke external programs in an elegant and convenient way.