Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/biopsy/base_extensions.rb

Overview

String

Class Method Summary collapse

Class Method Details

.which(cmd) ⇒ Object

return the full path to the supplied cmd executable, if it exists in any location in PATH



15
16
17
18
19
20
21
22
23
24
# File 'lib/biopsy/base_extensions.rb', line 15

def self.which(cmd)
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
    exts.each do |ext|
      exe = File.join(path, "#{cmd}#{ext}")
      return exe if File.executable? exe
    end
  end
  return nil
end