Skip to content

Class ShellInterpreter

Source: shellInterpreter.ts

Handles the parsing, expansion, and execution of shell commands and scripts. Manages the process pipeline and stream redirection.

Constructors

Constructor

new ShellInterpreter(shell: Shell): ShellInterpreter

Parameters

shell

Shell

Returns

ShellInterpreter

Properties

pipeline

pipeline: Process[] = []

Methods

terminatePipeline()

terminatePipeline(signal: StreamSignal): void

Sends a termination signal to all processes currently in the pipeline.

Parameters

signal

StreamSignal

The signal to send.

Returns

void


executeScript()

executeScript(script: string | VirtualFile): Promise<number>

Parses and executes a shell script.

Parameters

script

The script content or a virtual file.

string | VirtualFile

Returns

Promise<number>

The exit code of the last command executed in the script.


execute()

execute(input: string, streams?: { stdout?: Stream<string>; stderr?: Stream<string>; }): Promise<number>

Parses and executes an input string, handling environment expansion and piping.

Parameters

input

string

The raw command line string.

streams?

Optional output streams to override default TTY behavior.

stdout?

Stream<string>

stderr?

Stream<string>

Returns

Promise<number>

A promise that resolves with the final exit code of the execution.


spawn()

spawn(__namedParameters: Process): Promise<number>

Resolves a command, parses flags/options, and executes the command logic.

Parameters

__namedParameters

Process

Returns

Promise<number>

The resulting exit code from the command execution.


parseCommand()

static parseCommand(input: string): string[]

Splits a command string into an array of arguments, respecting single and double quotes.

Parameters

input

string

Returns

string[]

Built by Prozilla