lib/rbbt/util/cmd.rb in rbbt-util-5.38.1 vs lib/rbbt/util/cmd.rb in rbbt-util-5.39.0

- old
+ new

@@ -20,17 +20,21 @@ def self.get_tool(tool) return tool.to_s unless TOOLS[tool] @@init_cmd_tool ||= IndiferentHash.setup({}) + + claim, test, block, cmd = TOOLS[tool] + cmd = tool.to_s if cmd.nil? + if !@@init_cmd_tool[tool] - claim, test, block, cmd = TOOLS[tool] + begin if test CMD.cmd(test + " ") else - CMD.cmd("#{tool} --help") + CMD.cmd("#{cmd} --help") end rescue if claim claim.produce else @@ -39,11 +43,11 @@ end version_txt = "" version = nil ["--version", "-version", "--help", ""].each do |f| begin - version_txt += CMD.cmd("#{tool} #{f} 2>&1", :nofail => true).read + version_txt += CMD.cmd("#{cmd} #{f} 2>&1", :nofail => true).read version = Misc.scan_version_text(version_txt, tool) break if version rescue Log.exception $! end @@ -52,10 +56,10 @@ @@init_cmd_tool[tool] = version || true return cmd if cmd end - tool.to_s + cmd end def self.versions return {} unless defined? @@init_cmd_tool @@init_cmd_tool.select{|k,v| v =~ /\d+\./ }