class Sh
Run bash commands locally on machine.
Public Class Methods
new()
click to toggle source
# File lib/command/sh/sh.rb, line 7 def initialize; end
Public Instance Methods
run(command)
click to toggle source
Run a bash command locally.
# File lib/command/sh/sh.rb, line 10 def run(command) output = '' exit_status = nil Open3.popen3(command) do |_stdin, stdout, stderr, wait_thr| stdout.each_line do |line| puts line output += line end stderr.each_line do |line| puts line output += line end exit_status = wait_thr.value return { output: output, result: exit_status.success? } end end