lib/command/sh/sh.rb
# Run a bash command locally.
Run a bash command locally.
Run a bash command locally .
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
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
Run a bash command locally.
Run a bash command locally .
command