module Spielbash::CLI
Public Instance Methods
which(cmd)
click to toggle source
Cross-platform way of finding an executable in the $PATH.
which('ruby') #=> /usr/bin/ruby
# File lib/spielbash/view/cli.rb, line 16 def which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each {|ext| exe = File.join(path, "#{cmd}#{ext}") return true if File.executable?(exe) && !File.directory?(exe) } end false end