Merge pull request #8936 from rolandwalker/expand_tilde_path
expand tilde in `$PATH` for internal `which` method
This commit is contained in:
commit
a1db4377a1
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue