module SafeShell

Public Class Methods

execute(command, *args) click to toggle source
# File lib/git-smart/safe_shell.rb, line 2
def self.execute(command, *args)
  read_end, write_end = IO.pipe
  pid = fork do
    read_end.close
    STDOUT.reopen(write_end)
    STDERR.reopen(write_end)
    exec(command, *args)
  end
  write_end.close
  output = read_end.read
  Process.waitpid(pid)
  read_end.close
  output
end
execute?(*args) click to toggle source
# File lib/git-smart/safe_shell.rb, line 17
def self.execute?(*args)
  execute(*args)
  $?.success?
end