JustBash.Interpreter.Executor (JustBash v0.4.0)
View SourceExecutes parsed bash AST nodes.
This is the main entry point for script execution. Complex functionality is delegated to submodules:
Executor.Conditional- [[ ]] and if/case evaluationExecutor.Loop- for/while/until loopsExecutor.Redirection- File redirections (>, >>, <, etc.)
Summary
Functions
Execute a single command.
Execute a pipeline (commands connected by |).
Execute a parsed script AST. Returns {result, updated_bash}.
Execute a statement (one or more pipelines with && or ||).
Build the shell-shaped result for an exception that escaped containment.
Types
@type result() :: %{ :stdout => String.t(), :stderr => String.t(), :exit_code => non_neg_integer(), optional(:env) => map() }
Functions
@spec execute_command(JustBash.t(), JustBash.AST.command(), String.t()) :: {result(), JustBash.t()}
Execute a single command.
@spec execute_pipeline(JustBash.t(), JustBash.AST.Pipeline.t()) :: {result(), JustBash.t()}
Execute a pipeline (commands connected by |).
@spec execute_script(JustBash.t(), JustBash.AST.Script.t()) :: {result(), JustBash.t()}
Execute a parsed script AST. Returns {result, updated_bash}.
@spec execute_statement( JustBash.t(), JustBash.AST.Statement.t() | JustBash.AST.Group.t() ) :: {result(), JustBash.t()}
Execute a statement (one or more pipelines with && or ||).
@spec internal_error(JustBash.t(), String.t()) :: result()
Build the shell-shaped result for an exception that escaped containment.
Public so JustBash.exec/2's outer net reports the same way the statement
loop does. Exception.message/1 is unbounded from the sandbox's point of
view — inspect/1 alone allows 4096 bytes per binary and 50 collection
elements — so a MatchError or KeyError carrying interpreter or filesystem
state could inline sandbox file contents into a stderr the host asked to be
capped. The detail is truncated to fit :max_output_bytes, or 512 bytes,
whichever is smaller.