Module: Cliver::Which::Posix

Defined in:
lib/cliver/which/posix.rb

Overview

Posix implementation of Which Required and mixed into Cliver::Which in posix environments

Instance Method Summary collapse

Instance Method Details

#which(executable) ⇒ nil, String

Returns - path to found executable.

Parameters:

  • executable (String)

Returns:

  • (nil, String)
    • path to found executable



12
13
14
15
16
17
18
# File 'lib/cliver/which/posix.rb', line 12

def which(executable)
  # command -v is the POSIX-specified implementation behind which.
  # http://pubs.opengroup.org/onlinepubs/009695299/utilities/command.html
  which, status = Open3.capture2e('command', '-v', executable)
  return nil unless status.success?
  which.chomp
end