module Dory::Bash
Public Class Methods
escape_double_quotes(str)
click to toggle source
# File lib/dory/shell.rb, line 21 def self.escape_double_quotes(str) str.gsub('"', '\\"') end
escape_single_quotes(str)
click to toggle source
# File lib/dory/shell.rb, line 16 def self.escape_single_quotes(str) # Using this technique here: https://stackoverflow.com/a/1315213/2062384 str.gsub("'", "'\\\\''") end
run_command(command)
click to toggle source
# File lib/dory/shell.rb, line 25 def self.run_command(command) stdout = `bash -c "#{self.escape_double_quotes(command)}"` OpenStruct.new({ success?: $?.exitstatus == 0, exitstatus: $?.exitstatus, stdout: stdout }) end