Check File.file? first to avoid second stat()
This commit is contained in:
parent
6a0720071e
commit
7bd4f76b8c
@ -185,7 +185,7 @@ end
|
|||||||
def which cmd, path=ENV['PATH']
|
def which cmd, path=ENV['PATH']
|
||||||
path.split(File::PATH_SEPARATOR).each do |p|
|
path.split(File::PATH_SEPARATOR).each do |p|
|
||||||
pcmd = File.expand_path(File.join(p, cmd))
|
pcmd = File.expand_path(File.join(p, cmd))
|
||||||
return Pathname.new(pcmd) if File.executable?(pcmd) && !File.directory?(pcmd)
|
return Pathname.new(pcmd) if File.file?(pcmd) && File.executable?(pcmd)
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user