Skip to content

exec ​

exec starts one external program and connects its standard descriptors to bounded byte streams.

Signatureexec(command: string, args?: string[]): Result<ChildProcess, ProcessError>

Parameters ​

ParameterTypePurpose
commandstringExecutable path or command name.
argsstring[]?Individual arguments, or an omitted empty list.

Usage and errors ​

tyrus
import { ChildProcess, ProcessError, exec } from "tyrus:process";

async function run(): Promise<Result<i32, ProcessError>> {
    const child: ChildProcess = exec("tool", ["--version"])?;
    await child.stdin.close();
    return await child.wait();
}

error

tyrus
const child: ChildProcess = exec("tool", "--version"); 

Each argument is passed directly to the program. exec does not parse shell quoting, redirections, or pipelines. A start-time failure returns Err(ProcessError).