]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd-escape.xml
man: xinclude the generic text to talk about libsystemd pkgconfig
[thirdparty/systemd.git] / man / systemd-escape.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7
8 This file is part of systemd.
9
10 Copyright 2014 Lennart Poettering
11 -->
12
13 <refentry id="systemd-escape"
14 xmlns:xi="http://www.w3.org/2001/XInclude">
15
16 <refentryinfo>
17 <title>systemd-escape</title>
18 <productname>systemd</productname>
19
20 <authorgroup>
21 <author>
22 <contrib>Developer</contrib>
23 <firstname>Lennart</firstname>
24 <surname>Poettering</surname>
25 <email>lennart@poettering.net</email>
26 </author>
27 </authorgroup>
28 </refentryinfo>
29
30 <refmeta>
31 <refentrytitle>systemd-escape</refentrytitle>
32 <manvolnum>1</manvolnum>
33 </refmeta>
34
35 <refnamediv>
36 <refname>systemd-escape</refname>
37 <refpurpose>Escape strings for usage in systemd unit names</refpurpose>
38 </refnamediv>
39
40 <refsynopsisdiv>
41 <cmdsynopsis>
42 <command>systemd-escape</command>
43 <arg choice="opt" rep="repeat">OPTIONS</arg>
44 <arg choice="opt" rep="repeat">STRING</arg>
45 </cmdsynopsis>
46 </refsynopsisdiv>
47
48 <refsect1>
49 <title>Description</title>
50
51 <para><command>systemd-escape</command> may be used to escape
52 strings for inclusion in systemd unit names. The command may be
53 used to escape and to undo escaping of strings.</para>
54
55 <para>The command takes any number of strings on the command line,
56 and will process them individually, one after another. It will
57 output them separated by spaces to stdout.</para>
58
59 <para>By default, this command will escape the strings passed,
60 unless <option>--unescape</option> is passed which results in the
61 inverse operation being applied. If <option>--mangle</option> is given, a
62 special mode of escaping is applied instead, which assumes the
63 string is already escaped but will escape everything that
64 appears obviously non-escaped.</para>
65
66 <para>For details on the escaping and unescaping algorithms see the relevant section in
67 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
68 </refsect1>
69
70 <refsect1>
71 <title>Options</title>
72
73 <para>The following options are understood:</para>
74
75 <variablelist>
76 <varlistentry>
77 <term><option>--suffix=</option></term>
78
79 <listitem><para>Appends the specified unit type suffix to the
80 escaped string. Takes one of the unit types supported by
81 systemd, such as <literal>service</literal> or
82 <literal>mount</literal>. May not be used in conjunction with
83 <option>--template=</option>, <option>--unescape</option> or
84 <option>--mangle</option>.</para></listitem>
85 </varlistentry>
86
87 <varlistentry>
88 <term><option>--template=</option></term>
89
90 <listitem><para>Inserts the escaped strings in a unit name
91 template. Takes a unit name template such as
92 <filename>foobar@.service</filename>. May not be used in
93 conjunction with <option>--suffix=</option>,
94 <option>--unescape</option> or
95 <option>--mangle</option>.</para></listitem>
96 </varlistentry>
97
98 <varlistentry>
99 <term><option>--path</option></term>
100 <term><option>-p</option></term>
101
102 <listitem><para>When escaping or unescaping a string, assume it refers to a file system path. This eliminates
103 leading, trailing or duplicate <literal>/</literal> characters and rejects <literal>.</literal> and
104 <literal>..</literal> path components. This is particularly useful for generating strings suitable for
105 unescaping with the <literal>%f</literal> specifier in unit files, see
106 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
107 </para></listitem>
108 </varlistentry>
109
110 <varlistentry>
111 <term><option>--unescape</option></term>
112 <term><option>-u</option></term>
113
114 <listitem><para>Instead of escaping the specified strings,
115 undo the escaping, reversing the operation. May not be used in
116 conjunction with <option>--suffix=</option>,
117 <option>--template=</option> or
118 <option>--mangle</option>.</para></listitem>
119 </varlistentry>
120
121 <varlistentry>
122 <term><option>--mangle</option></term>
123 <term><option>-m</option></term>
124
125 <listitem><para>Like <option>--escape</option>, but only
126 escape characters that are obviously not escaped yet, and
127 possibly automatically append an appropriate unit type suffix
128 to the string. May not be used in conjunction with
129 <option>--suffix=</option>, <option>--template=</option> or
130 <option>--unescape</option>.</para></listitem>
131 </varlistentry>
132
133 <xi:include href="standard-options.xml" xpointer="help" />
134 <xi:include href="standard-options.xml" xpointer="version" />
135 </variablelist>
136
137 </refsect1>
138
139 <refsect1>
140 <title>Examples</title>
141
142 <para>To escape a single string:</para>
143 <programlisting>$ systemd-escape 'Hallöchen, Meister'
144 Hall\xc3\xb6chen\x2c\x20Meister</programlisting>
145
146 <para>To undo escaping on a single string:</para>
147 <programlisting>$ systemd-escape -u 'Hall\xc3\xb6chen\x2c\x20Meister'
148 Hallöchen, Meister</programlisting>
149
150 <para>To generate the mount unit for a path:</para>
151 <programlisting>$ systemd-escape -p --suffix=mount "/tmp//waldi/foobar/"
152 tmp-waldi-foobar.mount</programlisting>
153
154 <para>To generate instance names of three strings:</para>
155 <programlisting>$ systemd-escape --template=systemd-nspawn@.service 'My Container 1' 'containerb' 'container/III'
156 systemd-nspawn@My\x20Container\x201.service systemd-nspawn@containerb.service systemd-nspawn@container-III.service</programlisting>
157 </refsect1>
158
159 <refsect1>
160 <title>Exit status</title>
161
162 <para>On success, 0 is returned, a non-zero failure code
163 otherwise.</para>
164 </refsect1>
165
166 <refsect1>
167 <title>See Also</title>
168 <para>
169 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
170 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
171 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
172 </para>
173 </refsect1>
174
175 </refentry>