I'm shelling out of my Ruby script to call a system command as follows
puts "Reached point #1"
begin
system("sh my_shell_script.sh")
rescue StandardError => e
puts "There was an error"
end
puts "Reached point #2"
I purposely added an error in my shell script so it would fail (i.e. I spelled "echo" as "eho"). I would expect that my Ruby script would output that it reached marker #1, and then rescue the error to display "There was an error".
Instead, I'm getting:
"Reached point #1"
line 1: eho: command not found
"Reached point #2"
It certainly throws the correct error, but the shell error from system(...) isn't rescued. Any thoughts as to why?