startShellJob method

  1. @override
Future<Result<ShellJob, ExecutionError>> startShellJob(
  1. String command, {
  2. required String id,
  3. required String logPath,
  4. ShellExecOptions? options,
})
override

Starts command detached: stdout/stderr append to logPath and the returned ShellJob keeps running until it exits or is stopped. ShellExecOptions.timeout and ShellExecOptions.cancelToken still apply (both stop the job).

Implementation

@override
Future<Result<ShellJob, ExecutionError>> startShellJob(
  String command, {
  required String id,
  required String logPath,
  ShellExecOptions? options,
}) {
  final shell = _shell;
  if (shell case final BackgroundShell bg) {
    return bg.startShellJob(
      command,
      id: id,
      logPath: logPath,
      options: options,
    );
  }
  // A swapped-in shell (e.g. the sandboxed WASM shell) without the
  // background capability: clean error, never a crash.
  return Future.value(
    const Err(
      ExecutionError(
        ExecutionErrorCode.shellUnavailable,
        'background shell jobs are not supported by this shell',
      ),
    ),
  );
}