JustBash.Interpreter.Expansion.Brace (JustBash v0.4.0)

View Source

Brace expansion for bash.

Handles:

  • List expansion: {a,b,c}
  • Range expansion: {1..10}, {a..z}, {1..10..2}

Bounds

This is the one expansion whose output size is not bounded by anything the input already holds: {1..1000000} is twelve characters, and nesting multiplies. The word list is therefore produced under two bounds — the cardinality cap of Limit.check_expansion_words!/2 and the wall clock — both applied as each word is produced rather than after the list exists.

Summary

Types

Pending variable assignments from expansions

Functions

Expand brace expansion items (words and ranges).

Expand a range (numeric or character).

Expand word parts that may contain brace expansions. Returns {list_of_expanded_strings, pending_assignments}.

Check if word parts contain a brace expansion.

Types

pending_assignments()

@type pending_assignments() :: JustBash.Interpreter.Expansion.pending_assignments()

Pending variable assignments from expansions

Functions

expand_brace_items(bash, items)

@spec expand_brace_items(JustBash.t(), [JustBash.AST.brace_item()]) :: [String.t()]

Expand brace expansion items (words and ranges).

expand_range(start_val, end_val, step)

@spec expand_range(integer() | String.t(), integer() | String.t(), integer() | nil) ::
  [String.t()]

Expand a range (numeric or character).

expand_with_brace(bash, parts)

@spec expand_with_brace(JustBash.t(), [JustBash.AST.word_part()]) ::
  {[String.t()], pending_assignments()}

Expand word parts that may contain brace expansions. Returns {list_of_expanded_strings, pending_assignments}.

has_brace_expansion?(parts)

@spec has_brace_expansion?([JustBash.AST.word_part()]) :: boolean()

Check if word parts contain a brace expansion.