Module: ShellCmd

Defined in:
lib/shell_cmd.rb

Class Method Summary collapse

Class Method Details

.run(cmd) ⇒ Object

Run the command, displaying output as we get it, and return the process’s result code. Used mostly to avoid xkcd.com/303/



7
8
9
10
11
12
13
14
15
# File 'lib/shell_cmd.rb', line 7

def run(cmd)
  IO.popen(cmd) do |output|
    while c = output.getc do
      print c.chr
      STDOUT.flush
    end
  end
  $?.to_i
end