Skip to main content

Module scripting

Module scripting 

Source
Expand description

Minimal shell scripting: variable expansion, if, for, while.

ยงSupported constructs

  • Variables: set VAR=VALUE, $VAR expansion, $? for last exit code.
  • For loops: for VAR in A B C ; do COMMAND ; done
  • While loops: while COMMAND ; do BODY ; done
  • If/then: if COMMAND ; then BODY ; fi or if COMMAND ; then A ; else B ; fi

Enumsยง

ScriptConstruct
Script construct types recognized by the parser.

Staticsยง

LAST_EXIT ๐Ÿ”’
SHELL_VARS ๐Ÿ”’

Functionsยง

expand_vars
Expand $VAR and $? references in a string.
get_var
Get a shell variable.
last_exit
Get the exit code of the last executed command.
parse_for_loop ๐Ÿ”’
for VAR in A B C ; do cmd1 ; cmd2 ; done
parse_if_else ๐Ÿ”’
if cond ; then body ; [else body ;] fi
parse_script
Parse a full line into a script construct.
parse_while_loop ๐Ÿ”’
while cond ; do body ; done
set_last_exit
Set the exit code of the last executed command.
set_var
Set a shell variable.
unset_var
Remove a shell variable.