# msi: Macro Substitution and Include Tool ``` {program} msi ``` (msitool)= ## Introduction msi is a general purpose macro substitution/include tool. It accepts as input an ascii template file. It looks for lines containing two reserved command names: `include` and `substitute`. It also looks for and performs substitutions on macros of the form `$(var)` and `${var}`. It uses the macLib routines from EPICS Base to perform the substitutions, so it also accepts the default value and value definition syntax that macLib implements. msi also allows substitutions to be specified via a separate substitution file. This substitution file allows the same format as the substitution files accepted by the EPICS IOC's dbLoadTemplate command. ## Command Syntax ``` bash msi -V -g -o outfile -I dir -M subs -S subfile template ``` All parameters are optional. The -o, -I, -M, and -S switches may be separated from their associated value string by spaces if desired. Output will be written to stdout unless the -o option is given. Switches have the following meanings: ::: {option} -V Verbose warnings; if this parameter is specified then any undefined macro discovered in the template file which does not have an associated default value is considered an error. An error message is generated, and when msi terminates it will do so with an exit status of 2. ::: ::: {option} -g When this flag is given all macros defined in a substitution file will have global scope and thus their values will persist until a new value is given for this macro. This flag is provided for backwards compatibility as this was the behavior of previous versions of msi, but it does not follow common scoping rules and is discouraged. ::: ::: {option} -o Output will be written to the specified \ rather than to the standard output. ::: ::: {option} -I This parameter, which may be repeated or contain a colon-separated (or semi-colon separated on Windows) list of directory paths, specifies a search path for include commands. For example: ``` bash msi -I /home/mrk/examples:. -I.. template ``` specifies that all named files should be searched for in the following locations, in the order given: 1. `/home/mrk/examples` 2. `.` (the current directory) 3. `..` (the parent of the current directory) Note that relative path searching is handled as $ cat foo.substitutions file rel/path/bar.template { # contents } $ msi -I . -I /some/path foo.substitutions which will try to find `bar.template` at the path `./rel/path/` followed by `/some/path/rel/path`. ::: ::: {option} -M This parameter specifies macro values for the template instance. Multiple macro values can be specified in one substitution parameter, or in multiple -M parameters. For example: ``` bash msi -M "a=aval,b=bval" -Mc=cval template ``` specifies that in the template file each occurrence of: - `$(a)` or `${a}` is replaced by _aval_ - `$(b)` or `${b}` is replaced by _bval_ - `$(c)` or `${c}` is replaced by _cval_ ::: ::: {option} -S The substitution file. See below for format. ::: ::: {option}