ScriptPtyShellBackend class

A ShellBackend that runs interactive shells on a real pseudo-terminal allocated by the system script(1) utility — without dart:ffi or any native library.

It is the default PTY backend. Because the pty, forkpty and signal handling all live inside the script child process (an ordinary Process the VM reaps the safe way), it cannot trigger the native SIGCHLD crash that affects the FFI-based PtyShellBackend.

Like PtyShellBackend it decorates a fallback (the pipe-based ProcessShellBackend) and delegates to it when:

  • the request carries no PtySpec (e.g. exec mode), or
  • the platform is Windows (no POSIX script/forkpty), or
  • script is not installed, or a spawn fails — after the first such failure the script path is disabled for the process and every session uses the env-var fallback, which still conveys the initial geometry via COLUMNS/LINES.

Trade-off vs the native backend: script launched from pipes has no controlling terminal of its own, so live resize (SIGWINCH) cannot be propagated to the child — ScriptPtyShellSession.resize is a no-op. The initial geometry is still honoured (seeded via stty before exec).

Implemented types

Constructors

ScriptPtyShellBackend({required ShellBackend fallback, String? defaultShell, String? workingDirectory, Map<String, String> baseEnvironment = const {}, bool allowCommand(ShellRequest request)?, void onWarning(String message)?})
Creates a script-based PTY backend decorating fallback.

Properties

allowCommand bool Function(ShellRequest request)?
Optional guard; when it returns false the session is refused.
final
baseEnvironment Map<String, String>
Extra environment overlaid on the inherited environment for every session.
final
defaultShell String
The shell launched for interactive sessions without an explicit command.
final
fallback ShellBackend
Backend used for exec sessions and whenever the script path is unavailable.
final
hashCode int
The hash code for this object.
no setterinherited
onWarning → void Function(String message)?
Optional sink for a one-time warning when the script path is disabled.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
workingDirectory String?
Working directory applied when a request does not specify one.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
start(ShellRequest request) Future<ShellSession>
Starts a session for request, returning a live ShellSession.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited