43ff24c
From 9045c9cedb155255e4dd55b988a39093364efbac Mon Sep 17 00:00:00 2001
43ff24c
From: Lennart Poettering <lennart@poettering.net>
43ff24c
Date: Mon, 7 Jul 2014 22:48:25 +0200
43ff24c
Subject: [PATCH] man: document systemd-escape(1)
43ff24c
43ff24c
(cherry picked from commit 9869e75929acd9377aa460074334d8523cf8e822)
43ff24c
43ff24c
Conflicts:
43ff24c
	Makefile-man.am
43ff24c
---
43ff24c
 Makefile-man.am        |   2 +
43ff24c
 man/systemd-escape.xml | 193 +++++++++++++++++++++++++++++++++++++++++++++++++
43ff24c
 2 files changed, 195 insertions(+)
43ff24c
 create mode 100644 man/systemd-escape.xml
43ff24c
43ff24c
diff --git a/Makefile-man.am b/Makefile-man.am
43ff24c
index 5c289dda2a..4238c21710 100644
43ff24c
--- a/Makefile-man.am
43ff24c
+++ b/Makefile-man.am
43ff24c
@@ -63,6 +63,7 @@ MANPAGES += \
43ff24c
 	man/systemd-delta.1 \
43ff24c
 	man/systemd-detect-virt.1 \
43ff24c
 	man/systemd-efi-boot-generator.8 \
43ff24c
+	man/systemd-escape.1 \
43ff24c
 	man/systemd-fsck@.service.8 \
43ff24c
 	man/systemd-fstab-generator.8 \
43ff24c
 	man/systemd-getty-generator.8 \
43ff24c
@@ -1600,6 +1601,7 @@ EXTRA_DIST += \
43ff24c
 	man/systemd-delta.xml \
43ff24c
 	man/systemd-detect-virt.xml \
43ff24c
 	man/systemd-efi-boot-generator.xml \
43ff24c
+	man/systemd-escape.xml \
43ff24c
 	man/systemd-fsck@.service.xml \
43ff24c
 	man/systemd-fstab-generator.xml \
43ff24c
 	man/systemd-getty-generator.xml \
43ff24c
diff --git a/man/systemd-escape.xml b/man/systemd-escape.xml
43ff24c
new file mode 100644
43ff24c
index 0000000000..b2a4a9ce8c
43ff24c
--- /dev/null
43ff24c
+++ b/man/systemd-escape.xml
43ff24c
@@ -0,0 +1,193 @@
43ff24c
+ 
43ff24c
+
43ff24c
+        "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
43ff24c
+
43ff24c
+
43ff24c
+  This file is part of systemd.
43ff24c
+
43ff24c
+  Copyright 2014 Lennart Poettering
43ff24c
+
43ff24c
+  systemd is free software; you can redistribute it and/or modify it
43ff24c
+  under the terms of the GNU Lesser General Public License as published by
43ff24c
+  the Free Software Foundation; either version 2.1 of the License, or
43ff24c
+  (at your option) any later version.
43ff24c
+
43ff24c
+  systemd is distributed in the hope that it will be useful, but
43ff24c
+  WITHOUT ANY WARRANTY; without even the implied warranty of
43ff24c
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43ff24c
+  Lesser General Public License for more details.
43ff24c
+
43ff24c
+  You should have received a copy of the GNU Lesser General Public License
43ff24c
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
43ff24c
+-->
43ff24c
+
43ff24c
+
43ff24c
+          xmlns:xi="http://www.w3.org/2001/XInclude">
43ff24c
+
43ff24c
+        <refentryinfo>
43ff24c
+                <title>systemd-escape</title>
43ff24c
+                <productname>systemd</productname>
43ff24c
+
43ff24c
+                <authorgroup>
43ff24c
+                        <author>
43ff24c
+                                <contrib>Developer</contrib>
43ff24c
+                                <firstname>Lennart</firstname>
43ff24c
+                                <surname>Poettering</surname>
43ff24c
+                                <email>lennart@poettering.net</email>
43ff24c
+                        </author>
43ff24c
+                </authorgroup>
43ff24c
+        </refentryinfo>
43ff24c
+
43ff24c
+        <refmeta>
43ff24c
+                <refentrytitle>systemd-escape</refentrytitle>
43ff24c
+                <manvolnum>1</manvolnum>
43ff24c
+        </refmeta>
43ff24c
+
43ff24c
+        <refnamediv>
43ff24c
+                <refname>systemd-escape</refname>
43ff24c
+                <refpurpose>Escape strings for usage in system unit names</refpurpose>
43ff24c
+        </refnamediv>
43ff24c
+
43ff24c
+        <refsynopsisdiv>
43ff24c
+                <cmdsynopsis>
43ff24c
+                        <command>systemd-escape <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt" rep="repeat">STRING</arg></command>
43ff24c
+                </cmdsynopsis>
43ff24c
+        </refsynopsisdiv>
43ff24c
+
43ff24c
+        <refsect1>
43ff24c
+                <title>Description</title>
43ff24c
+
43ff24c
+                <para><command>systemd-escape</command> may be used to
43ff24c
+                escape strings for inclusion in systemd unit
43ff24c
+                names. The command may be used to escape and to undo
43ff24c
+                escaping of strings.</para>
43ff24c
+
43ff24c
+                <para>The command takes any number of strings on the
43ff24c
+                command line, and will process them individually, one
43ff24c
+                after the other. It will output them separated by
43ff24c
+                spaces to stdout.</para>
43ff24c
+
43ff24c
+                <para>By default this command will escape the strings
43ff24c
+                passed, unless <option>--unescape</option> is passed
43ff24c
+                which results in the inverse operation being
43ff24c
+                applied. If <option>--mangle</option> a special mode
43ff24c
+                of escaping is applied instead, which assumes a string
43ff24c
+                to be already escaped but will escape everything that
43ff24c
+                appears obviously non-escaped.</para>
43ff24c
+        </refsect1>
43ff24c
+
43ff24c
+        <refsect1>
43ff24c
+                <title>Options</title>
43ff24c
+
43ff24c
+                <para>The following options are understood:</para>
43ff24c
+
43ff24c
+                <variablelist>
43ff24c
+                        <varlistentry>
43ff24c
+                                <term><option>--suffix=</option></term>
43ff24c
+
43ff24c
+                                <listitem><para>Appends the specified
43ff24c
+                                unit type suffix to the escaped
43ff24c
+                                string. Takes one of the unit types
43ff24c
+                                supported by systemd, such as
43ff24c
+                                <literal>.service</literal> or
43ff24c
+                                <literal>.mount</literal>. May not be
43ff24c
+                                used in conjunction with
43ff24c
+                                <option>--template=</option>,
43ff24c
+                                <option>--unescape</option> or
43ff24c
+                                <option>--mangle</option>.</para></listitem>
43ff24c
+                        </varlistentry>
43ff24c
+
43ff24c
+                        <varlistentry>
43ff24c
+                                <term><option>--template=</option></term>
43ff24c
+
43ff24c
+                                <listitem><para>Inserts the escaped
43ff24c
+                                strings in a unit name template. Takes
43ff24c
+                                a unit name template such as
43ff24c
+                                <filename>foobar@.service</filename>
43ff24c
+                                May not be used in conjunction with
43ff24c
+                                <option>--suffix=</option>,
43ff24c
+                                <option>--unescape</option> or
43ff24c
+                                <option>--mangle</option>.</para></listitem>
43ff24c
+                        </varlistentry>
43ff24c
+
43ff24c
+                        <varlistentry>
43ff24c
+                                <term><option>--path</option></term>
43ff24c
+                                <term><option>-p</option></term>
43ff24c
+
43ff24c
+                                <listitem><para>When escaping or
43ff24c
+                                unescaping a string, assume it refers
43ff24c
+                                to a file system path. This enables
43ff24c
+                                special processing of the initial
43ff24c
+                                <literal>/</literal> of the
43ff24c
+                                path.</para></listitem>
43ff24c
+                        </varlistentry>
43ff24c
+
43ff24c
+                        <varlistentry>
43ff24c
+                                <term><option>--unescape</option></term>
43ff24c
+
43ff24c
+                                <listitem><para>Instead of escaping
43ff24c
+                                the specified strings, undo the
43ff24c
+                                escaping, reversing the operation. May
43ff24c
+                                not be used in conjunction with
43ff24c
+                                <option>--suffix=</option>,
43ff24c
+                                <option>--template=</option> or
43ff24c
+                                <option>--mangle</option>.</para></listitem>
43ff24c
+                        </varlistentry>
43ff24c
+
43ff24c
+                        <varlistentry>
43ff24c
+                                <term><option>--mangle</option></term>
43ff24c
+
43ff24c
+                                <listitem><para>Like
43ff24c
+                                <option>--escape</option>, but only
43ff24c
+                                escape characters that are obviously
43ff24c
+                                not escaped yet, and possibly
43ff24c
+                                automatically append an appropriate
43ff24c
+                                unit type suffix to the string. May
43ff24c
+                                not be used in conjunction with
43ff24c
+                                <option>--suffix=</option>,
43ff24c
+                                <option>--template=</option> or
43ff24c
+                                <option>--unescape</option>.</para></listitem>
43ff24c
+                        </varlistentry>
43ff24c
+
43ff24c
+                        <xi:include href="standard-options.xml" xpointer="help" />
43ff24c
+                        <xi:include href="standard-options.xml" xpointer="version" />
43ff24c
+                </variablelist>
43ff24c
+
43ff24c
+        </refsect1>
43ff24c
+
43ff24c
+        <refsect1>
43ff24c
+                <title>Examples</title>
43ff24c
+
43ff24c
+                <para>Escape a single string:</para>
43ff24c
+                <programlisting>$ systemd-escape 'Hallöchen, Meister'
43ff24c
+Hall\xc3\xb6chen\x2c\x20Meister</programlisting>
43ff24c
+
43ff24c
+                <para>To undo escaping on a single string:</para>
43ff24c
+                <programlisting>$ systemd-escape -u 'Hall\xc3\xb6chen\x2c\x20Meister'
43ff24c
+Hallöchen, Meister</programlisting>
43ff24c
+
43ff24c
+                <para>To generate the mount unit for a path:</para>
43ff24c
+                <programlisting>$ systemd-escape -p --suffix=mount "/tmp//waldi/foobar/"
43ff24c
+tmp-waldi-foobar.mount</programlisting>
43ff24c
+
43ff24c
+                <para>To generate instance names of three strings</para>
43ff24c
+                <programlisting>$ systemd-escape --template=systemd-nspawn@.service 'My Container 1' 'containerb' 'container/III'
43ff24c
+systemd-nspawn@My\x20Container\x201.service systemd-nspawn@containerb.service systemd-nspawn@container-III.service</programlisting>
43ff24c
+        </refsect1>
43ff24c
+
43ff24c
+        <refsect1>
43ff24c
+                <title>Exit status</title>
43ff24c
+
43ff24c
+                <para>On success, 0 is returned, a non-zero failure
43ff24c
+                code otherwise.</para>
43ff24c
+        </refsect1>
43ff24c
+
43ff24c
+        <refsect1>
43ff24c
+                <title>See Also</title>
43ff24c
+                <para>
43ff24c
+                        <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
43ff24c
+                        <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
43ff24c
+                </para>
43ff24c
+        </refsect1>
43ff24c
+
43ff24c
+</refentry>