start method

Future<WrappedProcess> start (
  1. String executable,
  2. Iterable<String> arguments
)

Implementation

Future<WrappedProcess> start(
    String executable, Iterable<String> arguments) async {
  var command = [executable]..addAll(arguments ?? []);

  if (sudo || username != null) {
    // sudo -k -p ''
    var sudoArgs = ['sudo', '-k', '-p', ''];
    if (username != null) sudoArgs.addAll(['-u', username]);
    if (password != null) sudoArgs.add('-S');
    command.insertAll(0, sudoArgs);
  }

  var p = await processManager.start(command,
      workingDirectory: workingDirectory,
      environment: environment,
      runInShell: runInShell,
      includeParentEnvironment: includeParentEnvironment);
  if ((sudo || username != null) && password != null)
    p.stdin.writeln(password);
  return new WrappedProcess(command.first, command.skip(1), p);
}