Project

General

Profile

Actions

Bug #8918

closed

Shell::CommandProcessor::find_system_command

Added by jimcox (James Cox) over 10 years ago. Updated over 10 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
[ruby-core:57235]

Description

I inherited some code which is using Shell::CommandProcessor::find_system_command to verify that the specified command actually exist, and get the full path to it. I pulled this small chunk out for testing:

require 'shell'
shell = Shell.new
puts shell.command_processor.find_system_command("perl")

The issues was triggered by someone running the rake system with a directory named "perl" on their path before the path which would find the actual perl command. To reproduce, I created a directory named "perl" in "~/bin". The user who hit the issue just has a collection of perl scripts in this directory. When "~/bin" is listed in the path before the real perl executable, the find_system_command function will return the directory named "perl" rather than the path to the perl command. This needs to have an added check to verify that the path found is an executable file, rather than a directory, and continue to search the path if directory.

I don't know if Shell::CommandProcessor::find_system_command is the best method for accomplishing this task since this seems to be listed as a private function on ruby-doc.org. I will probably need to just work around it for now, so I don't know if I will be checking back in on the bug. This seems to occur in both 1.9.1 (default on my system) and in the 2.0.0p247 I downloaded for evaluation recently.

$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r42961.
James, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


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]
Actions

Also available in: Atom PDF

Like0
Like0