Passing inner quotes from EnvironmentFile variable to ExecStart

environment-variablesescapingsystemd

In the EnvironmentFile I have:

EBUSD_OPTS="--scanconfig -d /dev/ttyEBUS -c /etc/ebusd --log=\"all notice\" --log=\"update error\""

In the .service file:

EnvironmentFile=-/etc/default/ebusd
ExecStart=/usr/bin/ebusd $EBUSD_OPTS

I would expect the quotes after –log= to be passed unchanged to the executable, but that doesn't seem to work. I've tried all types of double, single quotes, double, triple escaping the inner quotes, single outer quotes, etc. with no success.

Best Answer

Take the outside quotes out of the EnvironmentFile

EBUSD_OPTS=--scanconfig -d /dev/ttyEBUS -c /etc/ebusd --log="all notice" --log="update error"

and add braces in ExecStart.

ExecStart=/usr/bin/ebusd ${EBUSD_OPTS} 

I've also had to have a trailing space after the brace.