Sha256: 88d57f429d0bafaec0f7d63049d3e5938e2d81790a6accae69ad11989c1eca93
Contents?: true
Size: 579 Bytes
Versions: 21
Compression:
Stored size: 579 Bytes
Contents
# frozen_string_literal: true require "rbconfig" module EnvUtil def find_executable(cmd, *args) exts = RbConfig::CONFIG["EXECUTABLE_EXTS"].split | [RbConfig::CONFIG["EXEEXT"]] ENV["PATH"].split(File::PATH_SEPARATOR).each do |path| next if path.empty? path = File.join(path, cmd) exts.each do |ext| cmdline = [path + ext, *args] begin return cmdline if yield(IO.popen(cmdline, "r", err: [:child, :out], &:read)) rescue next end end end nil end module_function :find_executable end
Version data entries
21 entries across 20 versions & 6 rubygems