Module: Xcode::Shell
- Defined in:
- lib/xcode/shell.rb,
lib/xcode/shell/command.rb
Defined Under Namespace
Classes: Command, ExecutionError
Class Method Summary collapse
Class Method Details
.execute(bits, show_output = true) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/xcode/shell.rb', line 8 def self.execute(bits, show_output=true) out = [] cmd = bits.is_a?(Xcode::Shell::Command) ? bits.to_s : bits puts "EXECUTE: #{cmd}" IO.popen (cmd) do |f| f.each do |line| puts line if show_output yield(line) if block_given? out << line end end #Process.wait raise ExecutionError.new("Error (#{$?.exitstatus}) executing '#{cmd}'\n\n #{out.join(" ")}") if $?.exitstatus>0 #puts "RETURN: #{out.inspect}" out end |