[][src]Crate ichwh

ichwh - an async implementation of which

ichwh aims to be a fully-async clone of GNU which, compatible with the three major operating systems. Then main job of which is to search for executables on the current PATH.

Specialized Error and Result types are provided (through thiserror), and are returned by this crate's functions.

Usage

use ichwh::which;

async {
    let path_to_python = which("python").await.unwrap();
    assert_eq!(path_to_python.to_str().unwrap(), "/usr/bin/python");
};

Note about Windows

It's really simple to determine if a regular file or symlink is executable on Linux - you check that it has the executable permission, regardless of its extension.

On windows, it's a bit more complicated. In order to be executed, a file must have an executable extension in its name, such as .exe or .cmd. The executable file formats are listed in the %PATHEXT% environment variable. When searching for an executable in a directory, ichwh will 'match' files in the order that their extension appears in %PATHEXT%.

Enums

IchwhError

A specialized error type for the crate.

Functions

is_executable

Checks whether or not a file is executable.

which

Searches PATH for an executable with the name bin. The core functionality of the which command

which_all

Searches PATH for all executables with the name bin. Returns a list of paths, in the order of which they were found.

which_in_dir

Searches a directory for an exexcutable with the name bin.

Type Definitions

IchwhResult

A specialized result type for the crate