Sha256: 4c38d71940b884818b173871ca3a31dcaf632714d03231da8c7fbbd0c4ac0c28
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module FeduxOrg module Stdlib module Command module Which # Search for command # @param [String] cmd # name of command or path to command (will be reduced to basename and then searched in PATH) # # @param [Array,String] paths # a string containing paths separated by "File::PATH_SEPARATOR" or an array of paths # # @param [Array,String] pathexts # a string containing pathexts separated by ";" or an array of pathexts # # @return [String] # path to command def which(cmd, paths=ENV['PATH'].split(File::PATH_SEPARATOR), pathexts=ENV['PATHEXT'].to_s.split( /;/ ) ) return nil if cmd.blank? cmd = File.basename( cmd ) pathexts = [''] if pathexts.blank? Array( paths ).each do |path| Array( pathexts ).each do |ext| exe = File.join(path, "#{cmd}#{ext.to_s}") return exe if File.executable? exe end end nil end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fedux_org-stdlib-0.2.1 | lib/fedux_org/stdlib/command/which.rb |