Skip to content

Instantly share code, notes, and snippets.

@lusis
Created September 11, 2010 01:50
Show Gist options
  • Save lusis/574669 to your computer and use it in GitHub Desktop.
Save lusis/574669 to your computer and use it in GitHub Desktop.
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