Represents a single command execution with its own I/O streams.
Each command in a session gets its own Execution struct with separate StringIO devices for stdout and stderr. This enables:
- Per-command output inspection after execution
- Pipeline wiring (previous stdout becomes next stdin)
- Merged enumeration across all executions
Example
# Create execution for a command
{:ok, exec} = Execution.new("echo hello")
# Write to its streams
IO.puts(exec.stdout, "hello")
# Get output after completion
Execution.stdout_contents(exec) # => "hello\n"
Summary
Functions
Closes the StringIO devices for this execution.
Marks the execution as completed with the given exit code.
Creates a new Execution with fresh StringIO streams.
Gets the stderr contents from the execution.
Gets the stdout contents from the execution.
Types
@type t() :: %Bash.Execution{ command: String.t(), completed_at: DateTime.t() | nil, exit_code: 0..255 | nil, started_at: DateTime.t(), stderr: pid(), stdout: pid() }
Functions
@spec close(t()) :: :ok
Closes the StringIO devices for this execution.
Should be called when the execution is no longer needed to free resources.
Marks the execution as completed with the given exit code.
Creates a new Execution with fresh StringIO streams.
Examples
{:ok, exec} = Execution.new("echo hello")
IO.write(exec.stdout, "hello\n")
Gets the stderr contents from the execution.
Returns the accumulated output written to stderr.
Gets the stdout contents from the execution.
Returns the accumulated output written to stdout.