#set, #setenv, #unset, #unsetenv
With #set, and its variant #setenv, you can set environment variables. You can then reference these environment variables in subsequent preprocessor directives, such as #exec, #include, #verbatim, and #echo. (Note that legal environment variable names begin with a letter, followed by any sequence of letters, digits, and/or _ (underscore).)
So, for example, if you use
#set foo = "bar"or the variant
#setenv foo "bar"you could access the value of the $foo environment variable in a subsequent preprocessor directive.
If you don't specify a value, as in
#set foothe environment variable is implicitly set to 1. So the previous #set directive is equivalent to
#set foo = "1"and
#setenv foo "1"#unset and #unsetenv undo the effects of the #set and #setenv directives. So
#unset fooor
#unsetenv fooleaves the environment variable $foo undefined.
You may set (or unset) environment variables in this way to #include (or not) files (i.e., processes cat'ing the file(s)), or to access environment variable values using the #echo command, to pass parameters to processes embedded within preprocessor directives (e.g., #include [<proc>], or #exec [<proc], or to do some other clever thing.
For example, if you do this in one of your config files
#set foo #include <files/this_files.cfg> #unset fooyou could have in this_files.cfg
#include [test $foo && /bin/cat /pikt/lib/configs/files/that_files.cfg]or perhaps #include the output of some process
#include [/usr/local/bin/bar.pl]where bar.pl references the $foo environment variable, for example with
if ($ENV{foo}) { ... }Together with the piktc -|+ E (un)set environment variable option, #set, #setenv, #unset, #unsetenv and the other preprocessor directives make a very powerful combination. For some examples, refer to Introduction, also Samples and Developer's Notes.
![]() | next page ![]() |