morbig

A trustworthy parser for POSIX shell
Module Morbig . Aliases
type t

Type for a table of active aliases.

type aliases = t
val empty : t

empty is an empty alias table.

val interpret : t -> CST.complete_command -> t

interpret aliases cst traverses cst to check that there are no alias or unalias invocations in a nested command (that is, a compound command, or a function definition). These are allowed in POSIX, but we have to refuse them as they cannot be expanded statically.

  • if this is the case then it returns an alias table which is obtained from aliases by executing all alias and unalias invocations in cst;
  • if this is not the case then it raises Errors.DuringAliasing.
val alias_substitution : t -> 'a Parser.MenhirInterpreter.checkpoint -> string -> t * string

alias_substitution aliases checkpoint word substitutes an alias by its definition if word is not a reserved word and if the parsing context is about to reduce a cmd_name.