varrick
[] []
... | varrick
[] []
varrick
[] << template> [ > ]
varrick
is a template engine. It substitutes references of the form $var
and
${var}
with environment variables in a read from a file, piped or
redirected input.
The expanded template is saved at the location specified by .
When is read from a file and is an existing directory,
the result is saved in that directory under the template's filename without the
.tmpl
suffix if exists. Otherwise is interpreted as a file path
and the result is saved in the indicated file. In-place expansion is supported
for file paths. In all cases, parent directories must exist.
defaults to the standard output.
By default, varrick
expands undefined references to the empty string (just
like envsubst(1)). This behaviour can be changed with -e
to not expand
undefined references, or -m
to exit with an error when undefined references
are encountered.
-
-c
,--check
: Look for invalid escape sequences and exit. -
-e
,--no-expand
: Do not expand variables that are not defined. Mutually exclusive with-m
. -
-m
,--missing
: Report undefined variables and exit. Mutually exclusive with -e. -
-p
,--preprocess
: Escape variable references and backslashes and exit. -
-s
,--summary
: Print a list of referenced variables and exit. When used together with-x
escaped variables are reported separately. -
-x
,--escape
: Allow escaping variable references with a backslash. See [ESCAPING][].
Variable references can be escaped to prevent expansion using a backslash \
.
$ export name=value
$ echo '\$name' | varrick -x
$name
If a backslash appears in a non-escping position, i.e. not immediately before a variable reference, it has to be escaped.
$ echo 'text \\ text' | varrick -x
text \ text
When turning a file into a template, it is recommended to first escape all backslashes and strings that may be mistaken for references if necessary.
$ varrick -p < config.conf > config.conf.tmpl
Escaping backslashes in the substituted values is not necessary.
-
0
: Success. -
1
: An error occurred. -
2
: Internally used variable prefix detected in the environment. See [ENVIRONMENT][].
varrick
exits with an error when a variable starting with the prefix _d81e_
is defined in the environment. This is due to the fact that such variables are
used internally and allowing them in the environment would cause inconsistent
behaviour and hard to find errors.
Report bugs on Varrick's GitHub issue tracker at <https://github.com/ztombol/varrick/issues>.
varrick
exits when a variable starting with the prefix _d81e_
is defined in
the environment. This is NOT a bug, it is a mechanism guarding against
environment variables collding with inernally used variables. See
[ENVIRONMENT][] for more information.
Copyright (C) 2015-2016 Zoltan Tombol <zoltan (dot) tombol (at) gmail (dot) com>
Licensed under GNU GPL version 3 or any later version. You should have received a copy of the licence along with Varrick. If not, see <https://gnu.org/licenses/gpl.html>.
envsubst(1)