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.
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. The function is given the process identifier of the spawn, the environment if different from the program's one, the current working directory if different from the program's one and the acctual 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 B0.OS.Env.current_assignments (), cwd to Dir.current ().