Created
September 11, 2010 01:50
-
-
Save lusis/574669 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def executable_on_path(binary) | |
@matches = [] | |
ENV['PATH'].split(":").each do |path| | |
bintest = File.executable?("#{path}/#{binary}") | |
curtest = "#{path}/#{binary}" | |
@matches << curtest if bintest == true | |
end | |
case @matches.length | |
when 0 then | |
false | |
when 1 then | |
@matches[0] | |
else | |
false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment