Module: SystemWithAliases

Defined in:
lib/version.rb,
lib/system_with_aliases.rb

Overview

SystemWithAliases - execute system commands with aliases

Constant Summary collapse

VERSION =
'0.2'

Class Method Summary collapse

Class Method Details

.execute(command) ⇒ Object

Execute shell command, Return output, Run with aliases if possible.



24
25
26
27
28
# File 'lib/system_with_aliases.rb', line 24

def self.execute(command)
  expanded_command = expand(command)

  `#{expanded_command}`
end

.expand(command, shell = ENV['SHELL']) ⇒ Object

Expand command to one that would interpret aliases, If possible.



11
12
13
14
15
16
17
# File 'lib/system_with_aliases.rb', line 11

def self.expand(command, shell = ENV['SHELL'])
  if shell =~ /sh/
    "#{shell} -l -c '#{command}' 2>&1"
  else
    "#{command} 2>&1"
  end
end