Skip to content

Instantly share code, notes, and snippets.

@rebx
Created August 6, 2013 06:04
Show Gist options
  • Save rebx/6162403 to your computer and use it in GitHub Desktop.
Save rebx/6162403 to your computer and use it in GitHub Desktop.
# -*- encoding: utf-8 -*-
#
# taken from perl
# my bad perl habits aren't so easy to stomp out...tsk, tsk...
#
module File::Which
#
# Returns the full path to the executable
# @param exec [String] The name of the executable
# @return the full path to the executable
def self.which(exec)
begin
ENV['PATH'].split(File::PATH_SEPARATOR).any? do |pdir|
next unless File.executable?(File.join(pdir, exec))
return File.join(pdir, exec)
end
nil
rescue Exception
raise
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment