これは実際にはunix & linuxの質問です。しかし、それにもかかわらず:いいえ、systemd
は、Environment=
の中で環境変数拡張を行いません。 man systemd.exec
から:あなたはドキュメント$word
の例から見
Environment=
Sets environment variables for executed processes. Takes a space-separated list of variable assignments. This
option may be specified more than once, in which case all listed variables will be set. If the same variable is
set twice, the later setting will override the earlier setting. If the empty string is assigned to this option,
the list of environment variables is reset, all prior assignments have no effect. Variable expansion is not
performed inside the strings, however, specifier expansion is possible. The $ character has no special meaning.
If you need to assign a value containing spaces to a variable, use double quotes (") for the assignment.
Example:
Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
gives three variables "VAR1", "VAR2", "VAR3" with the values "word1 word2", "word3", "$word 5 6".
としてだけ$word
何の拡張が行われていないことを意味します。 指定子についてそのman
交渉があること%i
、%n
、%u
、など彼らは(自分のman
セクションの下)man systemd.unit
にしています。一方ExecStart=
およびその誘導体で
環境変数拡張を実行します。 ExecStart=
で環境変数を使用することは、systemd
の余分な環境変数の一般的な回避策です。私はがと信じています。それはまたのうちの1つで、多くの最近のプログラムが環境およびコマンドラインパラメータから同じパラメータを受け入れる理由です。 man systemd.service
から
ExecStart=
で
拡張の例、:
Example:
Environment="ONE=one" 'TWO=two two'
ExecStart=/bin/echo $ONE $TWO ${TWO}
This will execute /bin/echo with four arguments: "one", "two", "two", and "two two".
Example:
Environment=ONE='one' "TWO='two two' too" THREE=
ExecStart=/bin/echo ${ONE} ${TWO} ${THREE}
ExecStart=/bin/echo $ONE $TWO $THREE
This results in echo being called twice, the first time with arguments "'one'", "'two two' too", "", and the second
time with arguments "one", "two two", "too".
systemd
は、そのドキュメントはman
いくつかの年代全体に広がっているが、1は、しばらく後に、それらに使用されます。
私はUnix&Linuxサイトに適しているので、この質問を議論の対象外とすることにしました。プログラミングには直接関係しません。 http://unix.stackexchange.com/ –