Skip to content

sh

import { sh, ShellError } from 'sysopkit/op/sh';

Executes a command string via sh -c:

const result = await sh('hostname');

Throws ShellError on non-zero exit codes outside the 64-78 range.

const text = await sh('cat /etc/hostname');
class ShellError extends ExecError {
cmd: string;
exitCode: number;
stdout: string;
stderr: string;
toString(): string; // formatted error with all fields
}

Shell escaping:

const text = await sh(`cat ${$_(path)}`);