Skip to content

Instantly share code, notes, and snippets.

@mitchty
Created October 5, 2011 02:22
Show Gist options
  • Save mitchty/1263471 to your computer and use it in GitHub Desktop.
Save mitchty/1263471 to your computer and use it in GitHub Desktop.
type, in ruby, only crappily done and not cross platform, THE HORROR
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