Created
August 6, 2013 06:04
-
-
Save rebx/6162403 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
# | |
# taken from perl | |
# my bad perl habits aren't so easy to stomp out...tsk, tsk... | |
# | |
module File::Which | |
# | |
# Returns the full path to the executable | |
# @param exec [String] The name of the executable | |
# @return the full path to the executable | |
def self.which(exec) | |
begin | |
ENV['PATH'].split(File::PATH_SEPARATOR).any? do |pdir| | |
next unless File.executable?(File.join(pdir, exec)) | |
return File.join(pdir, exec) | |
end | |
nil | |
rescue Exception | |
raise | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment