caarlos0 caarlos0 - 1 year ago 79
Ruby Question

Make a rake task fail if system call return error

I have a Rakefile that I use to automate some tasks in my project.

Inside some tasks, I call

, but, even if the process return an error,
task continues without any issue.

How can I avoid that? I want to make rake exit when some subprocess return an error.

Thanks in advance

Answer Source

You can evaluate the return value of system

system('inexistent command') or exit!(1)
puts "This line is not reached"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download