Bash.AST.Command (Bash v0.3.0)

Copy Markdown View Source

Simple command: name with arguments and optional redirections.

Examples

# echo hello world
%Command{
  name: %Word{parts: [{:literal, "echo"}]},
  args: [
    %Word{parts: [{:literal, "hello"}]},
    %Word{parts: [{:literal, "world"}]}
  ]
}

# VAR=value command arg
%Command{
  name: %Word{parts: [{:literal, "command"}]},
  args: [%Word{parts: [{:literal, "arg"}]}],
  env_assignments: [{"VAR", %Word{parts: [{:literal, "value"}]}}]
}

# command < input.txt > output.txt
%Command{
  name: %Word{parts: [{:literal, "command"}]},
  redirects: [
    %Redirect{direction: :input, target: "input.txt"},
    %Redirect{direction: :output, target: "output.txt"}
  ]
}

Summary

Types

t()

@type t() :: %Bash.AST.Command{
  args: [Bash.AST.Word.t()],
  env_assignments: [{String.t(), Bash.AST.Word.t()}],
  exit_code: 0..255 | nil,
  meta: Bash.AST.Meta.t(),
  name: Bash.AST.Word.t(),
  redirects: [Bash.AST.Redirect.t()],
  state_updates: map()
}

Functions

execute(ast, stdin, session_state)