Created
October 5, 2011 02:22
-
-
Save mitchty/1263471 to your computer and use it in GitHub Desktop.
type, in ruby, only crappily done and not cross platform, THE HORROR
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
def type(name) | |
ENV['PATH'].split(File::PATH_SEPARATOR).each do |p| | |
que = p + File::SEPARATOR + name | |
return que if File.exists?(que) and File.executable?(que) | |
end | |
false | |
end | |
type 'foo' # false | |
type 'openssl' # '/usr/bin/openssl' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment