runExecutableArgumentsSync function

ProcessResult runExecutableArgumentsSync(
  1. String executable,
  2. List<String> arguments, {
  3. ShellOptions? options,
  4. String? workingDirectory,
  5. Map<String, String>? environment,
  6. bool includeParentEnvironment = true,
  7. bool? runInShell,
  8. Encoding? stdoutEncoding = systemEncoding,
  9. Encoding? stderrEncoding = systemEncoding,
  10. StreamSink<List<int>>? stdout,
  11. StreamSink<List<int>>? stderr,
  12. bool? verbose,
  13. bool? commandVerbose,
  14. bool? throwOnError,
})

if commandVerbose or verbose is true, display the command. if verbose is true, stream stdout & stdin

Does not throw by default if no options are given.

Compared to the async version, it is not possible to kill the spawn process nor to feed any input.

Implementation

ProcessResult runExecutableArgumentsSync(
  String executable,
  List<String> arguments, {

  /// Prefer options
  ShellOptions? options,
  String? workingDirectory,
  Map<String, String>? environment,
  bool includeParentEnvironment = true,
  bool? runInShell,
  Encoding? stdoutEncoding = systemEncoding,
  Encoding? stderrEncoding = systemEncoding,
  StreamSink<List<int>>? stdout,
  StreamSink<List<int>>? stderr,
  bool? verbose,
  bool? commandVerbose,

  /// Compat default to false
  bool? throwOnError,
}) {
  throwOnError ??= false;
  options ??= ShellOptions(
    verbose: verbose ?? false,
    commandVerbose: commandVerbose,
    stderrEncoding: stderrEncoding,
    stdoutEncoding: stdoutEncoding,
    workingDirectory: workingDirectory,
    stdout: stdout,
    stderr: stderr,
    environment: environment,
    includeParentEnvironment: includeParentEnvironment,
    runInShell: runInShell,
    throwOnError: false,
  );
  var result = Shell(
    options: options,
  ).runExecutableArgumentsSync(executable, arguments);

  return result;
}