exec method

  1. @override
Future<Result<ShellExecResult, ExecutionError>> exec(
  1. String command, {
  2. ShellExecOptions? options,
})
override

Executes a shell command. Must never throw: all failures are encoded in the returned Result.

Implementation

@override
Future<Result<ShellExecResult, ExecutionError>> exec(
  String command, {
  ShellExecOptions? options,
}) async {
  final vars = await _vars();
  if (vars.isEmpty) return _delegate.exec(command, options: options);
  // Per-call env entries win over the injected session vars.
  final merged = ShellExecOptions(
    cwd: options?.cwd,
    env: {...vars, ...?options?.env},
    timeout: options?.timeout,
    cancelToken: options?.cancelToken,
    onStdout: options?.onStdout,
    onStderr: options?.onStderr,
    // stdinData + liveStdin (issue #367): the live stdin channel keeps
    // the pipe open so a mid-run password ask can be answered; the
    // launch-time stdin param rides the same merge.
    stdinData: options?.stdinData,
    liveStdin: options?.liveStdin,
  );
  return _delegate.exec(command, options: merged);
}