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