I am writing some scripts in Ruby, and I need to interact with non-Ruby code using shell commands. I know that there are at least 6 different ways to execute shell commands from Ruby, but, unfortunately, none of them stops execution when a shell command fails.
Essentially, I'm looking for something that matches:
set -o errexit
... in the Bash script. Ideally, the solution should throw an exception when the command fails (i.e., by checking for a non-zero return value), possibly with stderr as the message. It would not be too difficult to write, but it seems that it should already exist. Is there an option that I just can't find?
source share