Top Level Namespace

Defined Under Namespace

Modules: Kernel Classes: Exit_0

Instance Method Summary collapse

Instance Method Details

#Exit_0(*cmd, &blok) ⇒ Object

Kernel

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/Exit_0.rb', line 18

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

#Exit_Zero(*cmd, &blok) ⇒ Object

Exit_0



41
42
43
# File 'lib/Exit_0.rb', line 41

def Exit_Zero *cmd, &blok
  Exit_0 *cmd, &blok
end