|
|
8d419f |
From 05ea18897aeafa1f2d47c5eae6c43bdd6ff71b9d Mon Sep 17 00:00:00 2001
|
|
|
8d419f |
From: Yonathan Randolph <yonathan@gmail.com>
|
|
|
8d419f |
Date: Sun, 26 Dec 2021 17:12:00 -0800
|
|
|
8d419f |
Subject: [PATCH] man: clarify Environmentfile format
|
|
|
8d419f |
|
|
|
8d419f |
Remove incorrect claim that C escapes (such as \t and \n) are recognized and that control characters are disallowed. Specify the allowed characters and escapes with single quotes, with double quotes, and without quotes.
|
|
|
8d419f |
|
|
|
8d419f |
(cherry picked from commit 4bbcde8498eb59557ebddd7830efb47c0297ff4b)
|
|
|
8d419f |
|
|
|
8d419f |
Related: #2017035
|
|
|
8d419f |
---
|
|
|
8d419f |
man/systemd.exec.xml | 51 ++++++++++++++++++++++++++++----------------
|
|
|
8d419f |
1 file changed, 33 insertions(+), 18 deletions(-)
|
|
|
8d419f |
|
|
|
8d419f |
diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
|
|
|
8d419f |
index cd21d5b28d..69858d5e59 100644
|
|
|
8d419f |
--- a/man/systemd.exec.xml
|
|
|
8d419f |
+++ b/man/systemd.exec.xml
|
|
|
8d419f |
@@ -2485,18 +2485,39 @@ SystemCallErrorNumber=EPERM</programlisting>
|
|
|
8d419f |
<varlistentry>
|
|
|
8d419f |
<term><varname>EnvironmentFile=</varname></term>
|
|
|
8d419f |
|
|
|
8d419f |
- <listitem><para>Similar to <varname>Environment=</varname> but reads the environment variables from a text
|
|
|
8d419f |
- file. The text file should contain new-line-separated variable assignments. Empty lines, lines without an
|
|
|
8d419f |
- <literal>=</literal> separator, or lines starting with ; or # will be ignored, which may be used for
|
|
|
8d419f |
- commenting. A line ending with a backslash will be concatenated with the following one, allowing multiline
|
|
|
8d419f |
- variable definitions. The parser strips leading and trailing whitespace from the values of assignments, unless
|
|
|
8d419f |
- you use double quotes (").</para>
|
|
|
8d419f |
-
|
|
|
8d419f |
- <para><ulink url="https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences">C escapes</ulink>
|
|
|
8d419f |
- are supported, but not
|
|
|
8d419f |
- <ulink url="https://en.wikipedia.org/wiki/Control_character#In_ASCII">most control characters</ulink>.
|
|
|
8d419f |
- <literal>\t</literal> and <literal>\n</literal> can be used to insert tabs and newlines within
|
|
|
8d419f |
- <varname>EnvironmentFile=</varname>.</para>
|
|
|
8d419f |
+ <listitem><para>Similar to <varname>Environment=</varname> but reads the environment variables from a text file.
|
|
|
8d419f |
+ The text file should contain newline-separated variable assignments. Empty lines, lines without an
|
|
|
8d419f |
+ <literal>=</literal> separator, or lines starting with <literal>;</literal> or <literal>#</literal> will be
|
|
|
8d419f |
+ ignored, which may be used for commenting. The file must be UTF-8 encoded. Valid characters are
|
|
|
8d419f |
+ url="https://www.unicode.org/glossary/#unicode_scalar_value">unicode scalar values</ulink> other than
|
|
|
8d419f |
+ url="https://www.unicode.org/glossary/#noncharacter">noncharacters</ulink>, U+0000 NUL, and U+FEFF
|
|
|
8d419f |
+ url="https://www.unicode.org/glossary/#byte_order_mark">byte order mark</ulink>. Control codes other than NUL
|
|
|
8d419f |
+ are allowed.</para>
|
|
|
8d419f |
+
|
|
|
8d419f |
+ <para>In the file, an unquoted value after the <literal>=</literal> is parsed with the same backslash-escape
|
|
|
8d419f |
+ rules as
|
|
|
8d419f |
+ url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_01">unquoted
|
|
|
8d419f |
+ text</ulink> in a POSIX shell, but unlike in a shell, interior whitespace is preserved and quotes after the
|
|
|
8d419f |
+ first non-whitespace character are preserved. Leading and trailing whitespace (space, tab, carriage return) is
|
|
|
8d419f |
+ discarded, but interior whitespace within the line is preserved verbatim. A line ending with a backslash will be
|
|
|
8d419f |
+ continued to the following one, with the newline itself discarded. A backslash
|
|
|
8d419f |
+ <literal>\</literal> followed by any character other than newline will preserve the following character, so that
|
|
|
8d419f |
+ <literal>\\</literal> will become the value <literal>\</literal>.</para>
|
|
|
8d419f |
+
|
|
|
8d419f |
+ <para>In the file, a <literal>'</literal>-quoted value after the <literal>=</literal> can span multiple lines
|
|
|
8d419f |
+ and contain any character verbatim other than single quote, like
|
|
|
8d419f |
+ url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_02">single-quoted
|
|
|
8d419f |
+ text</ulink> in a POSIX shell. No backslash-escape sequences are recognized. Leading and trailing whitespace
|
|
|
8d419f |
+ outside of the single quotes is discarded.</para>
|
|
|
8d419f |
+
|
|
|
8d419f |
+ <para>In the file, a <literal>"</literal>-quoted value after the <literal>=</literal> can span multiple lines,
|
|
|
8d419f |
+ and the same escape sequences are recognized as in
|
|
|
8d419f |
+ url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03">double-quoted
|
|
|
8d419f |
+ text</ulink> of a POSIX shell. Backslash (<literal>\</literal>) followed by any of <literal>"\`$</literal> will
|
|
|
8d419f |
+ preserve that character. A backslash followed by newline is a line continuation, and the newline itself is
|
|
|
8d419f |
+ discarded. A backslash followed by any other character is ignored; both the backslash and the following
|
|
|
8d419f |
+ character are preserved verbatim. Leading and trailing whitespace outside of the double quotes is
|
|
|
8d419f |
+ discarded.</para>
|
|
|
8d419f |
|
|
|
8d419f |
<para>The argument passed should be an absolute filename or wildcard expression, optionally prefixed with
|
|
|
8d419f |
<literal>-</literal>, which indicates that if the file does not exist, it will not be read and no error or
|
|
|
8d419f |
@@ -2529,12 +2550,6 @@ SystemCallErrorNumber=EPERM</programlisting>
|
|
|
8d419f |
<para>Variables set for invoked processes due to this setting are subject to being overridden by those
|
|
|
8d419f |
configured with <varname>Environment=</varname> or <varname>EnvironmentFile=</varname>.</para>
|
|
|
8d419f |
|
|
|
8d419f |
- <para><ulink url="https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences">C escapes</ulink>
|
|
|
8d419f |
- are supported, but not
|
|
|
8d419f |
- <ulink url="https://en.wikipedia.org/wiki/Control_character#In_ASCII">most control characters</ulink>.
|
|
|
8d419f |
- <literal>\t</literal> and <literal>\n</literal> can be used to insert tabs and newlines within
|
|
|
8d419f |
- <varname>EnvironmentFile=</varname>.</para>
|
|
|
8d419f |
-
|
|
|
8d419f |
<para>Example:
|
|
|
8d419f |
<programlisting>PassEnvironment=VAR1 VAR2 VAR3</programlisting>
|
|
|
8d419f |
passes three variables <literal>VAR1</literal>,
|