lib/rbbt/util/cmd.rb in rbbt-util-5.26.150 vs lib/rbbt/util/cmd.rb in rbbt-util-5.26.151

- old
+ new

@@ -27,18 +27,34 @@ claim.produce else block.call end end - @@init_cmd_tool[tool] = true + version_txt = "" + %w(--version -version --help).each do |f| + begin + version_txt += CMD.cmd("#{tool} #{f}").read + break + rescue + end + end + version = Misc.scan_version_text(version_txt, tool) + + @@init_cmd_tool[tool] = version || true + return cmd if cmd end tool.to_s end + def self.versions + return {} unless defined? @@init_cmd_tool + @@init_cmd_tool.select{|k,v| v =~ /\d+\./ } + end + def self.gzip_pipe(file) Open.gzip?(file) ? "<(gunzip -c '#{file}')" : "'#{file}'" end def self.bash(cmd) @@ -86,10 +102,10 @@ dont_close_in = options.delete(:dont_close_in) log = true if log.nil? - if cmd.nil? and ! Symbol === tool + if cmd.nil? && ! Symbol === tool cmd = tool else tool = get_tool(tool) if cmd.nil? cmd = tool