Module: Dory::Bash

Defined in:
lib/dory/shell.rb

Class Method Summary collapse

Class Method Details

.escape_double_quotes(str) ⇒ Object



16
17
18
# File 'lib/dory/shell.rb', line 16

def self.escape_double_quotes(str)
  str.gsub('"', '\\"')
end

.run_command(command) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/dory/shell.rb', line 20

def self.run_command(command)
  stdout = `bash -c "#{self.escape_double_quotes(command)}"`
  OpenStruct.new({
    success?: $?.exitstatus == 0,
    exitstatus: $?.exitstatus,
    stdout: stdout
  })
end