launchesForegroundProgram function

bool launchesForegroundProgram(
  1. String line
)

Whether line launches an interactive foreground program that should take over the terminal (so the client switches to raw passthrough).

Returns false for empty lines, for lines containing shell operators (too ambiguous to treat as one foreground program — the marker chaining handles those), and for REPLs in _interactiveWhenBare that were given an argument.

Implementation

bool launchesForegroundProgram(String line) {
  final lineTrimmed = line.trim();
  if (lineTrimmed.isEmpty) return false;

  final tokens = _significantTokens(line);
  if (tokens.isEmpty) return false;
  if (_shellOperators.hasMatch(line)) return false;

  final program = _basename(tokens.first);
  if (_alwaysInteractive.contains(program)) return true;
  if (_interactiveWhenBare.contains(program)) {
    // Bare invocation (no positional argument) → an interactive session.
    return tokens.length == 1;
  }
  return false;
}