Top Level Namespace

Defined Under Namespace

Classes: Exit_0

Constant Summary collapse

Exit_0_Version =
"1.4.1"

Instance Method Summary collapse

Methods included from Exit_0::Top_Methods

#exit_0

Instance Method Details

#Exit_0(*cmd, &blok) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/Exit_0.rb', line 6

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



29
30
31
# File 'lib/Exit_0.rb', line 29

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