JustBash.Interpreter.Executor.Conditional (JustBash v0.4.0)

View Source

Evaluates conditional expressions for [[ ]] and if statements.

Supports:

  • Unary file tests: -e, -f, -d, -r, -w, -x, -s, -L, -h, etc.
  • Unary string tests: -z, -n
  • Binary string comparisons: =, ==, !=, <, >
  • Binary integer comparisons: -eq, -ne, -lt, -le, -gt, -ge
  • Binary file comparisons: -nt, -ot, -ef
  • Pattern matching: ==, =~
  • Logical operators: &&, ||, !

Summary

Functions

Evaluate a conditional expression AST node. Returns {result, updated_bash} where result is true or false. The bash struct may be updated (e.g. BASH_REMATCH after =~).

Types

unary_op_type()

@type unary_op_type() ::
  :file_exists
  | :regular_file
  | :directory
  | :file_size
  | :string_empty
  | :string_non_empty
  | :symlink
  | :var_set
  | :always_false

Functions

evaluate(bash, arg2)

Evaluate a conditional expression AST node. Returns {result, updated_bash} where result is true or false. The bash struct may be updated (e.g. BASH_REMATCH after =~).