Method: Bj::Util::ModuleMethods#spawn

Defined in:
lib/bj/util.rb

#spawn(cmd, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/bj/util.rb', line 22

def spawn cmd, options = {}
  options.to_options!
  logger = options.has_key?(:logger) ? options[:logger] : Bj.logger
  logger.info{ "cmd <#{ cmd }>" } if logger
  status = systemu cmd, 1=>(stdout=""), 2=>(stderr="")
  logger.info{ "status <#{ status.exitstatus }>" } if logger
  status.exitstatus.zero? or raise "#{ cmd.inspect } failed with #{ $?.inspect }"
  [ stdout, stderr ]
end