Class: PivotalIntegration::Util::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotal-integration/util/shell.rb

Overview

Utilities for dealing with the shell

Class Method Summary collapse

Class Method Details

.exec(command, abort_on_failure = true) ⇒ String

Executes a command

Parameters:

  • command (String)

    the command to execute

  • abort_on_failure (Boolean) (defaults to: true)

    whether to Kernel#abort with FAIL as the message when the command’s Status#existstatus is not 0

Returns:

  • (String)

    the result of the command



27
28
29
30
31
32
33
34
# File 'lib/pivotal-integration/util/shell.rb', line 27

def self.exec(command, abort_on_failure = true)
  result = `#{command}`
  if $?.exitstatus != 0 && abort_on_failure
    abort 'FAIL'
  end

  result
end