Module: Byebug::MiscUtils
- Included in:
- Runner
- Defined in:
- lib/byebug/helper.rb
Overview
Miscelaneous Utilities
Instance Method Summary collapse
-
#which(cmd) ⇒ Object
Cross-platform way of finding an executable in the $PATH.
Instance Method Details
#which(cmd) ⇒ Object
Cross-platform way of finding an executable in the $PATH. Borrowed from: stackoverflow.com/questions/2108727
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/byebug/helper.rb', line 10 def which(cmd) return File.(cmd) if File.exist?(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable?(exe) && !File.directory?(exe) end end nil end |