shell
Run child processes.
Import
ts
import { ShellResult, ShellProcess, Shell } from "shell";Needs the "shell" permission in thicket.json.
ShellResult class
ts
class ShellResultShellResult.exitCode
ts
exitCode: intExit code of the child process.
ShellResult.ok
ts
ok: booleanTrue if exitCode is 0.
ShellResult.stderr
ts
stderr: stringStandard error output from the child process.
ShellResult.stdout
ts
stdout: stringStandard output from the child process.
ShellProcess class
ts
class ShellProcessShellProcess.kill
ts
kill(signal?: string): voidSend a signal to the child process. signal defaults to "SIGTERM"; recognized signals include "SIGTERM", "SIGKILL", "SIGSTOP", "SIGCONT", "SIGINT".
Parameters
signal: Signal name as a string; defaults to"SIGTERM".
ShellProcess.on
ts
on(event: string, handler: any): voidRegister an event handler. Recognized events: "exit" (passes exit code), "stdout" (passes accumulated stdout data), "stderr" (passes accumulated stderr data).
Parameters
event: Event name:"exit","stdout", or"stderr".handler: Callback; receives the event data (exit code as int, or data as string).
Shell static class
ts
static class ShellShell.exec
ts
static exec(cmd: string, opts?: any): anyExecute a command synchronously and return a Promise<ShellResult>. The command string is parsed (no shell expansion; supports single and double quotes and backslash escapes). Options may include cwd (working directory) and timeout (milliseconds).
Parameters
cmd: Command string to parse and execute.opts: Optional{cwd?: string, timeout?: int}.
Returns: Promise that resolves to a ShellResult when the process exits.
Shell.spawn
ts
static spawn(cmd: string): anySpawn a child process and return a ShellProcess handle (Unix/Linux only). The command string is parsed the same way as exec. Output is streamed to handlers registered via process.on("stdout"|"stderr"|"exit", ...).
Parameters
cmd: Command string to parse and execute.
Returns: ShellProcess; use .on() to listen for output and exit.
Generated from lang/types/shell.d.tks in the ThicketScript repository.