1ESH(1)                                                                  ESH(1)
2
3
4

NAME

6       esh - simple template system based on shell
7

SYNOPSIS

9       esh [-d] [-o output] [-s shell] [--] file [variable ...]
10
11       esh <-h | -V>
12

DESCRIPTION

14       esh (embedded shell) is a templating engine for evaluating shell
15       commands embedded in arbitrary templates. It’s like ERB (Embedded RuBy)
16       for shell, intended to be used for templating configuration files.
17
18       esh converts template file, or stdin if file is “-”, into a sequence of
19       shell commands. Commands between <% and %> tags are passed as-is,
20       everything else is escaped and prefixed with printf command. These
21       commands are eventually evaluated using shell (unless -d is specified).
22

OPTIONS

24       -d
25           Don’t evaluate template, just dump a shell script.
26
27       -o file
28           Output file or “-” for STDOUT. Defaults to “-”.
29
30       -s shell
31           Command name or path of the shell to use for template evaluation.
32           It must not contain spaces. Defaults to “/bin/sh”.
33
34       -h
35           Show help message and exit.
36
37       -V
38           Print version and exit.
39

ENVIRONMENT

41       esh may be configured using the following environment variables:
42
43       ESH_AWK
44           Command name of path of the awk program to use. It must not contain
45           spaces. Defaults to “awk”.
46
47       ESH_SHELL
48           The same as -s shell.
49

EXIT STATUS

51       esh exits with the exit status of shell or awk.
52

TEMPLATE SYNTAX

54       ESH has two tags for shell code, a tag for comments, and a way to
55       escape tag delimiters.
56
57       <% commands %>
58           Executes the commands and replaces this tag with its output on
59           stdout.
60
61       <%= values %>
62           Executes printf '%s ' with the values as arguments and replaces
63           this tag with the output (without trailing white space). values are
64           not quoted or escaped, so all shell substitutions are applied.
65
66       <%# comment %>
67           Removed from the final output.
68
69       -%>
70           May be used instead of %>. It trims the following line break if
71           used at the end of line, otherwise has no trimming effect.
72
73       <%%
74           A literal <% when used outside of the above tags.
75
76       %%>
77           A literal %> when used inside of the above tags.
78
79       Opening and closing tag may not be at the same line.
80
81       Text outside a tag becomes literal text, but it is subject to any
82       tagged shell code surrounding it. For example, text surrounded by a
83       tagged if statement only appears in the output if the condition is
84       true.
85

EXAMPLES

87       nginx.conf.esh
88
89           http {
90               access_log <%= $logs_dir/access.log %> main;
91
92               resolver <%= $(sed -En 's/^nameserver ([^#]+)/\1/p' /etc/resolv.conf) %>;
93
94               <% if nginx -V 2>&amp;1 | grep -q lua-nginx-module; then -%>
95               lua_package_path '<%= $(pkg-config --variable=INSTALL_LMOD lua) %>/?.lua';
96               <% fi -%>
97
98               <%# The rest of the config is omitted %>
99           }
100
101       To generate the resulting configuration file run:
102
103           esh -o nginx.conf nginx.conf.esh logs_dir=/var/log/nginx
104

AUTHORS

106       esh’s author is Jakub Jirutka.
107

REPORTING BUGS

109       Report bugs to the project’s issue tracker at <https://github.com/
110       jirutka/esh/issues>.
111

SEE ALSO

113       sh(1)
114
115
116
117                                  2017-11-18                            ESH(1)
Impressum