Method: Kernel.executable_exists?

Defined in:
lib/dbgeni.rb

.executable_exists?(cmd) ⇒ Boolean

Returns:

  • (Boolean)

21
22
23
24
25
26
27
28
29
30
# File 'lib/dbgeni.rb', line 21

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