Lynxer

Documentation

shell

Run external shell commands and inspect available shells.

Backend: native — stdlib/shell.so, built from stdlib/shell.cpp over popen and std::system. Import: import("shell") → global.shell.*

Commands run through the platform shell (/bin/sh -c).

FunctionSignatureNotes
runShell(str command) -> intRuns with inherited streams; returns the exit code
runShellCapture(str command) -> strCaptures stdout
runShellSilent(str command) -> intRuns with output discarded
runShellErr(str command) -> strCaptures stderr only
runShellCode(str command) -> intRuns silently; returns the exit code
runShellAs(str shell, str command) -> intRuns via the named shell
runShellCaptureAs(str shell, str command) -> strCaptures stdout via the named shell
commandExists(str command) -> boolResolves on PATH
checkShell(str shell) -> boolWhether the shell is available
shellPath(str command) -> strResolved path, or ""
shellVersion(str shell) -> strFirst line of shell --version
availableShells() -> strJSON array of installed shells
currentShell() -> str$SHELL, or ""

Example

global setup(){ import("shell"); }

global main(){
    println(global.shell.runShellCapture("printf hello"));
    println(global.shell.shellPath("sh"));
    println(global.shell.availableShells());
    println(global.shell.runShellCode("exit 3"));
}

See also