From d0260aee604b9eaec090c04c27d15e604f5cac28 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 17 Sep 2013 06:54:04 +0000 Subject: [PATCH] command-processor.rb: return executable file only * lib/shell/command-processor.rb (Shell::CommandProcessor#find_system_command): return executable file only, should ignore directories and unexecutable files. [ruby-core:57235] [Bug #8918] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 +++++- lib/shell/command-processor.rb | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b687bf4882..29a15c90d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -Tue Sep 17 15:53:20 2013 Nobuyoshi Nakada +Tue Sep 17 15:54:03 2013 Nobuyoshi Nakada + + * lib/shell/command-processor.rb (Shell::CommandProcessor#find_system_command): + return executable file only, should ignore directories and + unexecutable files. [ruby-core:57235] [Bug #8918] * lib/test/unit/assertions.rb (Test::Unit::Assertions#assert_throw): assertion for throw. MiniTest::Assertions#assert_throws discards diff --git a/lib/shell/command-processor.rb b/lib/shell/command-processor.rb index f52d0ead6d..8a9ab55e73 100644 --- a/lib/shell/command-processor.rb +++ b/lib/shell/command-processor.rb @@ -369,7 +369,12 @@ class Shell for p in @shell.system_path path = join(p, command) - if FileTest.exist?(path) + begin + st = File.stat(path) + rescue SystemCallError + next + else + next unless st.executable? and !st.directory? @system_commands[command] = path return path end