Re:Unix Wildcards Gone Wild (2014)
by woodruffw on Saturday June 23, 2018 @12:24AM
(#17379535)
> Ruby is kind of clumsy for doing all the command piping parts of scripting, though; especially since there's no easy way short of wrapping Kernel.system in your own function to make a Ruby script crash on a nonzero subshell exit status.
You can do this by checking `$?`, and wrapping that check in a small function:
def safer_system(*args)
system *args
raise "command failed with status: #{$?.exitstatus}" unless $?.success?
end
(It might be small consolation, but Ruby 2.6 is also adding `exception: true` to `Kernel#system`)[1].
You can do this by checking `$?`, and wrapping that check in a small function:
(It might be small consolation, but Ruby 2.6 is also adding `exception: true` to `Kernel#system`)[1].[1]: https://bugs.ruby-lang.org/issues/14386