What is the syntax for EnvironmentFile in systemd?

Asked 2 years ago, Updated 2 years ago, 64 views

Failed to read man systemd.exec to set environment variables in systemd's service.So the explanation was as follows:

Similar to Environment= but reads the environment variables from a text file. The text file should contain new-line-separated variable assignments. Empty lines, lines without an "=" separator, or lines starting with ; or # will be ignored, which may be used for commenting. A line ending with a backslash will be concatenated with the following one, allowing multiline variable definitions. The parser strings leading and training white space from the values of assignments, unless you use double quotes(").

However, for example, this information alone is not clear what syntax double quotes are handled in.Also, I'm reading the man page that might be relevant, but I haven't found out what syntax this EnvironmentFile expects.

  • Is the EnvironmentFile grammar (syntax) defined for systemd?
    • In particular, I would like to know the specifications for specialized notation, such as processing around double quote.
  • In particular, I would like to know the specifications for specialized notation, such as processing around double quote.

linux systemd

2022-09-30 10:42

1 Answers

Systemd.exec(5) on systemd-245.7/fedora32 had an example.
"I don't have a specific explanation for "" Syntax, but I don't know why.

"

If you need to assign a value containing spaces or the equals sign to a variable,
use double quotes(") for the assignment.

Example:

    Environment="VAR1=word1word2"VAR2=word3"VAR3=$word56"


2022-09-30 10:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.