5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/Exit_0.rb', line 5
def Exit_0 *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_0::Child.new(*cmd)
msg = p.err.strip.empty? ? p.cmd : p.err
msg << " (command: #{cmd})"
end
(r = r.status) if r.respond_to?(:status)
raise(Exit_0::Unknown_Exit, msg.inspect) unless r.respond_to?(:exitstatus)
raise(Exit_0::Non_0, "#{r.exitstatus} => #{msg}") if r.exitstatus != 0
p
end
|