Module: SafeShell
- Defined in:
- lib/git-smart/safe_shell.rb
Class Method Summary collapse
Class Method Details
.execute(command, *args) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# 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) ⇒ Boolean
17 18 19 20 |
# File 'lib/git-smart/safe_shell.rb', line 17 def self.execute?(*args) execute(*args) $?.success? end |