[前][次][番号順一覧][スレッド一覧]

ruby-changes:30882

From: nobu <ko1@a...>
Date: Tue, 17 Sep 2013 15:54:09 +0900 (JST)
Subject: [ruby-changes:30882] nobu:r42961 (trunk): command-processor.rb: return executable file only

nobu	2013-09-17 15:54:04 +0900 (Tue, 17 Sep 2013)

  New Revision: 42961

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42961

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/lib/shell/command-processor.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42960)
+++ ChangeLog	(revision 42961)
@@ -1,4 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Tue Sep 17 15:53:20 2013  Nobuyoshi Nakada  <nobu@r...>
+Tue Sep 17 15:54:03 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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
Index: lib/shell/command-processor.rb
===================================================================
--- lib/shell/command-processor.rb	(revision 42960)
+++ lib/shell/command-processor.rb	(revision 42961)
@@ -369,7 +369,12 @@ class Shell https://github.com/ruby/ruby/blob/trunk/lib/shell/command-processor.rb#L369
 
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]