Merge pull request #8936 from rolandwalker/expand_tilde_path

expand tilde in `$PATH` for internal `which` method
This commit is contained in:
Roland Walker 2015-01-16 06:41:57 -05:00
commit a1db4377a1
1 changed files with 2 additions and 2 deletions

View File

@ -106,13 +106,13 @@ module Hbc::Utils
def self.which(cmd, path=ENV['PATH'])
unless File.basename(cmd) == cmd.to_s
# path contains a directory element
# cmd contains a directory element
cmd_pn = Pathname(cmd)
return nil unless cmd_pn.absolute?
return resolve_executable(cmd_pn)
end
path.split(File::PATH_SEPARATOR).each do |elt|
fq_cmd = Pathname(elt).join(cmd)
fq_cmd = Pathname(elt).expand_path.join(cmd)
resolved = resolve_executable fq_cmd
return resolved if resolved
end