Search a command in the bin folder
Note: the command locator is not injected because it needs the relative bin path.
435406
public function getBinCommand(string $command, bool $forceUnix = false): string
    {
        return $this->externalCommandLocator->locate($command, $forceUnix);
    }
1288758
def do_search(self, line):
        
        args = self._split_args(line, 0, -1)
        query = " ".join([_f for _f in args if _f])
        self._command_processor.search(query)
161841
function getBinPath(cmd, fn) {
  which(cmd, function(err, bin) {
    if (err) {
      return fn(err);
    }

    fs.exists(bin, function(exists) {
      if (!exists) {
        return fn(new Error(format(
          'Expected file for `%s` does not exist at `%s`',
          cmd, bin)));
      }
      fn(null, bin);
    });
  });
}
1134388
def _findSwiplDar():
    

    # If the exec is in path
    (path, swiHome) = _findSwiplFromExec()
    if path is not None:
        return (path, swiHome)

    # If it is not, use  find_library
    path = _findSwiplPathFromFindLib()
    if path is not None:
        return (path, swiHome)

    # Last guess, searching for the file
    paths = ['.', './lib', '/usr/lib/', '/usr/local/lib', '/opt/local/lib']
    names = ['libswipl.dylib', 'libpl.dylib']

    for name in names:
        for path in paths:
            path = os.path.join(path, name)
            if os.path.exists(path):
                return (path, None)

    return (None, None)
679991
def _search_path(self, directory_name, filename):
        """"""
        full_path = path.join(directory_name, filename)
        if path.exists(full_path):
            return full_path

        # Could not find the requested file in any of the directories
        return None
1032309
def locate_tool(name, verbose=True): 
    
    m = get_tool(name) 
    tool_bin = which(m.cmd) 
    if tool_bin:
        if verbose:
            print("Found {} in {}".format(m.name, tool_bin)) 
        return tool_bin 
    else: 
        print("Couldn't find {}".format(m.name))
1048322
function getBinPath(packageInstallFolder, binName) {
    const binFolderPath = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin');
    const resolvedBinName = (os.platform() === 'win32') ? `${binName}.cmd` : binName;
    return path.resolve(binFolderPath, resolvedBinName);
}
195878
def search_paths(path = ENV['PATH'])
      paths = if path && !path.empty?
                path.split(::File::PATH_SEPARATOR)
              else
                %w(/usr/local/bin /usr/ucb /usr/bin /bin)
              end
      paths.select(&Dir.method(:exist?))
    end
1255216
def command_in_path?(command)
      found = ENV['PATH'].split(File::PATH_SEPARATOR).map do |p|
        File.exist?(File.join(p, command))
      end
      found.include?(true)
    end
1117938
def search(pkg_name, **kwargs):
    '''
    
    '''

    pkglist = {}
    pkgin = _check_pkgin()
    if not pkgin:
        return pkglist

    if _supports_regex():
        pkg_name = '^{0}$'.format(pkg_name)

    out = __salt__['cmd.run'](
        [pkgin, 'se', pkg_name],
        output_loglevel='trace'
    )
    for line in out.splitlines():
        if line:
            match = _splitpkg(line.split()[0])
            if match:
                pkglist[match[0]] = match[1]

    return pkglist
890021
def find_in_path(name, path):
    ""
    # adapted fom http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/
    for dir in path.split(os.pathsep):
        binpath = os.path.join(dir, name)
        if os.path.exists(binpath):
            return os.path.abspath(binpath)
    return None
1165384
def recursive_search glob="**/*"
      @command = Proc.new {|str| Dir.glob(glob).select do |p| p.index str; end }
    end
771332
def _search_for_executable(self, executable):
        
        if os.path.isfile(executable):
            return os.path.abspath(executable)
        else:
            envpath = os.getenv('PATH')
            if envpath is None:
                return
            for path in envpath.split(os.pathsep):
                exe = os.path.join(path, executable)
                if os.path.isfile(exe):
                    return os.path.abspath(exe)
210936
def _get_base_command(self):
        
        command_parts = []
        cd_command = ''.join(['cd ', str(self.WorkingDir), ';'])
        if self._command is None:
            raise ApplicationError('_command has not been set.')
        command = self._command
        parameters = sorted([str(x) for x in self.Parameters.values()
                            if str(x)])

        synonyms = self._synonyms

        command_parts.append(cd_command)
        command_parts.append(command)
        command_parts.append(self._database)  # Positional argument
        command_parts.append(self._query)  # Positional argument
        command_parts += parameters
        if self._output:
            command_parts.append(self._output.Path)  # Positional

        return (
            self._command_delimiter.join(filter(None, command_parts)).strip()
        )
1081447
def find_file(path, search_path):
    

    if isinstance(search_path, str):
        search_path = [search_path]
    for relative in search_path:
        candidate = os.path.normpath(os.path.join(relative, path))
        if os.path.isfile(candidate):
            return candidate

    return None
1040318
def _check_directory(directory):
    """"""
    if directory is not None:
        if not exists(directory):
            raise CommandError(
                "Cannot run command - directory {0} does not exist".format(directory)
            )

        if not isdir(directory):
            raise CommandError(
                "Cannot run command - specified directory {0} is not a directory.".format(
                    directory
                )
            )
890252
def find_pattern(search_base, pattern='*.rpm'):
    
    # Stolen from http://rosettacode.org/wiki/Walk_a_directory/Recursively#Python
    if (not os.path.isdir(search_base)) and os.path.exists(search_base):
        # Adapt the algorithm to gracefully handle non-directory search paths
        yield search_base
    else:
        for root, dirs, files in os.walk(search_base):
            for filename in fnmatch.filter(files, pattern):
                yield os.path.join(root, filename)