diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-11 09:42:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-11 09:42:46 +0000 |
commit | e77a9ad446dc1a7bb69ef706ce8c4ded28b86ced (patch) | |
tree | a143926f322ff7566fa136b033c7808f207ce487 /lib/mkmf.rb | |
parent | 23f2460e820ad8ec99cf81ff39f3e9adce67b15d (diff) | |
download | ruby-e77a9ad446dc1a7bb69ef706ce8c4ded28b86ced.tar.gz |
* lib/mkmf.rb (find_executable0): should exclude directories.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/mkmf.rb')
-rw-r--r-- | lib/mkmf.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb index cc9f918958..260875f732 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1327,11 +1327,20 @@ end # Internal use only. # def find_executable0(bin, path = nil) + executable_file = proc do |name| + begin + stat = File.stat(name) + rescue SystemCallError + else + next name if stat.file? and stat.executable? + end + end + exts = config_string('EXECUTABLE_EXTS') {|s| s.split} || config_string('EXEEXT') {|s| [s]} if File.expand_path(bin) == bin - return bin if File.executable?(bin) + return bin if executable_file.call(bin) if exts - exts.each {|ext| File.executable?(file = bin + ext) and return file} + exts.each {|ext| executable_file.call(file = bin + ext) and return file} end return nil end @@ -1342,9 +1351,9 @@ def find_executable0(bin, path = nil) end file = nil path.each do |dir| - return file if File.executable?(file = File.join(dir, bin)) + return file if executable_file.call(file = File.join(dir, bin)) if exts - exts.each {|ext| File.executable?(ext = file + ext) and return ext} + exts.each {|ext| executable_file.call(ext = file + ext) and return ext} end end nil |