module Hirb::Util
Public Class Methods
command_exists?(command)
click to toggle source
Determines if a shell command exists by searching for it in ENV. (Fixed version)
# File lib/spirit_hands/hirb/fixes/util.rb, line 7 def command_exists?(command) if c = Pathname.new(command) return true if c.absolute? && c.exist? end executable_file_exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).any? do |d| executable_file_exts.any? do |ext| f = File.expand_path(command + ext, d) File.executable?(f) && !File.directory?(f) end end end