lib/image_optimizer/shell.rb
# Cross-platform way of finding an executable in the $PATH.
Cross-platform way of finding an executable in the $PATH.
Cross - platform way of finding an executable in the $PATH .
def which(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
          end
        end
        nil
      end
def which ( 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 end end nil end
Cross-platform way of finding an executable in the $PATH.
Cross - platform way of finding an executable in the $PATH .
cmd
<not_specific>