runScript method

  1. @override
Future<ShellProcessResults> runScript(
  1. String script, {
  2. ShellCommandRunOptions? options,
})

Run one or multiple plain text command(s).

Commands can be split by line.

Commands can be on multiple line if ending with ^ or \.

Returns a list of executed command line results.

onProcess is called for each started process.

Implementation

@override
Future<ShellProcessResults> runScript(
  String script, {
  ShellCommandRunOptions? options,
}) async {
  var commands = shellScriptSplitLines(script);

  var processResults = <ShellProcessResult>[];
  for (var command in commands) {
    // Display the comments
    if (isLineComment(command)) {
      continue;
    }
    var shellCommand = ShellCommand.parse(command);

    var processResult = await runCommand(shellCommand, options: options);
    processResults.add(processResult);
  }

  var result = ShellProcessResultInternalList.fromList(
    this as Shell,
    processResults,
  );
  return result;
}