Skip to content

Instantly share code, notes, and snippets.

@stereobooster
Created July 16, 2011 23:49
Show Gist options
  • Save stereobooster/1086931 to your computer and use it in GitHub Desktop.
Save stereobooster/1086931 to your computer and use it in GitHub Desktop.
Information about environment path
executables = {}
total = 0
path_extensions = ENV["PATHEXT"].gsub(".", "").downcase.split(File::PATH_SEPARATOR)
path = ENV["Path"]
path.split(File::PATH_SEPARATOR).each do |value|
dir = Pathname.new(value)
if dir.exist? then
filter = File.join(dir.realpath, "*.{" + path_extensions.join(",") + "}")
Dir.glob(filter).each do |file|
basename = File.basename(file)
extension = File.extname(file)
filename = basename.gsub(extension, '')
executables[filename] ||= []
executables[filename] << file
total += 1
end
else
p value
end
end
executables.each do |name, value|
if value.length > 1 then
p value
end
end
p total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment