Top Level Namespace
Defined Under Namespace
Classes: Exit_Zero
Instance Method Summary collapse
Instance Method Details
#Exit_Zero(*cmd, &blok) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/Exit_Zero.rb', line 5 def Exit_Zero *cmd, &blok both = !cmd.empty? && block_given? raise ArgumentError, "Both command and block are not allowed." if both if block_given? cmd = blok r = p = blok.call msg = cmd else r = p = Exit_Zero::Child.new(*cmd) msg = p.err.strip.empty? ? p.cmd : p.err end (r = r.status) if r.respond_to?(:status) raise(Exit_Zero::Unknown_Exit, msg.inspect) unless r.respond_to?(:exitstatus) raise(Exit_Zero::Non_Zero, "#{r.exitstatus} => #{msg}") if r.exitstatus != 0 p end |