이것은 실제로 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
의 추가 환경 변수에 대한 일반적인 해결 방법입니다. I
이인데,
중 하나 인입니다. 많은 최근 프로그램이 환경 및 명령 줄 매개 변수에서 동일한 매개 변수를 허용하는 이유입니다.
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
여러 년대에 걸쳐 퍼져있다, 그러나 하나가 잠시 후 그들에게 사용됩니다.
유닉스 및 리눅스 사이트에 더 적합하기 때문에이 질문을 주제로 끝내기로했습니다. 프로그래밍과 직접적인 관련이 없습니다. http://unix.stackexchange.com/ –