Legend:
Library
Module
Module type
Parameter
Class
Class type
Executing commands.
Tool search
Portability. In order to maximize portability no .exe suffix should be added to executable names on Windows, tool search adds the suffix during the tool search procedure.
find_tool ~search tool is the file path, if any, to the program executable for the tool specification tool.
If tool has a single path segment. The tool file is searched, in list order, for the first matching executable file in the directories of search. These directories default to those that result from parsing PATH with Fpath.list_of_search_path.
If tool has multiple path segments the corresponding file is simply tested for existence and executability. Ok (Some tool) is returned if that is case and Ok None otherwise.
The type for representing the standard output of a process.
val out_file : ?mode:int ->force:bool ->make_path:bool ->Fpath.t->stdo
out_file ~force ~make_path file is a standard output that writes to file file.
If make_path is true and the parent directory of file does not exist the whole path to the parent is created as needed with permission 0o755 (readable and traversable by everyone, writable by the user).
If force is true and file exists at call time as a regular file it tries to overwrite it, in all other cases the function errors if file exists.
mode are the permissions of the written file; they default to 0o644, readable by everyone, writable by the user.
run_status ~env ~cwd ~stdin ~stdout ~stderr cmd runs and waits for the completion of cmd in environment env with current directory cwd and standard IO connections stdin, stdout and stderr.
run_status_out is like run_status except stdout is read from the process to a string. The string is String.trimed if trim is true (default). If stderr is `Out the process' stderr is redirected to stdout and thus read back in the string aswell.
Note. In contrast to waitpid(2) the following API does not allow to collect any child process completion. There are two reasons: first this is not supported on Windows, second this is anti-modular.
spawn ~env ~cwd ~stdin ~stdout ~stderr cmd spawns command cmd in environment env with current directory cwd and standard IO connections stdin, stdout and stderr. env defaults to Env.current_assignments (), cwd to Dir.current
(), stdin to in_stdin, stdout to out_stdout and stderr to out_stderr.
spawn_poll_status pid tries to collect the exit status of command spawn pid. If block is false, Ok None is immediately returned if pid has not terinated yet.
The type for spawn tracers. Called with each blocking and non-blocking spawned command aswell as execv. The function is given the process identifier of the spawn (or None in case of execv), the environment if different from the program's one, the current working directory if different from the program's one and the actual command.
Windows. On Windows a program executing an execv* function yields back control to the terminal as soon as the child starts (vs. ends on POSIX). This entails all sorts of unwanted behaviours. To workaround this, the following function executes, on Windows, the file as a spawned child process which is waited on for completion via waitpid(2). Once the child process has terminated the calling process is immediately exited with the status of the child.
execv ~env ~cwd f argv executes file f as a new process in environment env with args as the Sys.argv of this process (in particular Sys.argv.(0) is the name of the program not the first argument to the program). The function only recturns in case of error. env defaults to B00.OS.Env.current_assignments (), cwd to Dir.current ().