provisionBashGuard function

Future<BashGuardProvision?> provisionBashGuard({
  1. String chmodCommand = 'chmod',
})

Provisions the guard once per process. POSIX only — null on Windows and on any failure (never throws). chmodCommand exists for tests: it lets a suite force the chmod step to fail (false) and pin the degrade-to-no-shim behavior.

Implementation

Future<BashGuardProvision?> provisionBashGuard({
  String chmodCommand = 'chmod',
}) async {
  if (Platform.isWindows) return null;
  try {
    final pids = await _protectedPidChain();
    final shims = await _buildShimScripts();
    final shimDir = shims.isEmpty
        ? null
        : await _writeShimDir(shims, chmodCommand: chmodCommand);
    return BashGuardProvision(shimDir: shimDir, protectedPids: pids);
  } on Object {
    return null;
  }
}