module Byebug::Helpers::BinHelper - byebug-11.0.1 Documentation

# module Byebug::Helpers::BinHelper

Utilities for interaction with executables

### Public Instance Methods

executable_file_extensions() click to toggle source

    # File lib/byebug/helpers/bin.rb, line 38
    def executable_file_extensions
      ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
    end

find_executable(path, cmd) click to toggle source

    # File lib/byebug/helpers/bin.rb, line 24
    def find_executable(path, cmd)
      executable_file_extensions.each do |ext|
        exe = File.expand_path(cmd + ext, path)

        return exe if real_executable?(exe)
      end

      nil
    end

real_executable?(file) click to toggle source

    # File lib/byebug/helpers/bin.rb, line 42
    def real_executable?(file)
      File.executable?(file) && !File.directory?(file)
    end

search_paths() click to toggle source

    # File lib/byebug/helpers/bin.rb, line 34
    def search_paths
      ENV["PATH"].split(File::PATH_SEPARATOR)
    end

which(cmd) click to toggle source

Cross-platform way of finding an executable in the $PATH. Adapted from: gist.github.com/steakknife/88b6c3837a5e90a08296

    # File lib/byebug/helpers/bin.rb, line 13
    def which(cmd)
      return File.expand_path(cmd) if File.exist?(cmd)

      [nil, *search_paths].each do |path|
        exe = find_executable(path, cmd)
        return exe if exe
      end

      nil
    end