Class: Array

Inherits:
Object show all
Defined in:
lib/string__.rb

Instance Method Summary collapse

Instance Method Details

#whichObject



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/string__.rb', line 81

def which
  each do |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) && !File.directory?(exe)
      end
    end
    nil
  end
end