How can I use spaces in systemd command line arguments?

前端 未结 7 1502
情话喂你
情话喂你 2021-01-17 11:52

I have a systemd unit with spaces in an argument

ExecStart=command --argument=\"text text\"

It seems that systemd does not recognize the do

7条回答
  •  無奈伤痛
    2021-01-17 11:55

    I think recent versions of systemd have started accepting quotes in the middle of arguments, closer to what bash accepts. However, @Tgr's answer is still correct, and it's worth elaborating on. Quoting the entire argument, including the flag name, works here. If you do this:

    ExecStart=command "--argument=text text"
    

    Then systemd will understand --argument=text text as a single positional argument. You don't have to worry about any more splitting happening on that space. You can see the same behavior in bash:

    $ echo "--silly-flag=spaces     are    preserved here"
    --silly-flag=spaces     are    preserved here
    

提交回复
热议问题