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

Posix adapter to ‘which`

Parameters:

  • executable (String)

Returns:

  • (nil, String)
    • path to found executable



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

def which(executable)
  which = `which #{Shellwords.escape executable} 2>&1`
  executable_path = which.chomp
  return nil if executable_path.empty?
  executable_path
rescue Errno::ENOENT
  raise '"which" must be on your path to use Cliver on this system.'
end