davmac314 / dinit

Service monitoring / "init" system
Apache License 2.0
622 stars 49 forks source link

Escaping a newline in dinit service causes an error #291

Closed squeaktoy closed 5 months ago

squeaktoy commented 9 months ago

I tried to write a service with a long command so I naturally thought "let's escape the newline with backslash!" but nope, doing so results in this error:

Checking service: slskd...
Service 'slskd' (line 2): backslash escape (`\') not followed by character
Unable to load service 'slskd': badly formed line.
One or more errors/warnings issued.

The slskd service file looks like this:

type = process
command = bwrap --bind $HOME/.local/share/slskd $HOME/.local/share/slskd \
--bind /media/tank/archive /media/tank/archive \
--bind /media/tank/music /media/tank/music \
--bind /media/tank/movies /media/tank/movies \
--bind /media/tank/sound /media/tank/sound \
--bind /media/tank/games /media/tank/games \
--bind /media/tank/downloads/soulseek /media/tank/downloads/soulseek \
--unshare-cgroup --unshare-ipc --unshare-pid --unshare-uts \
--proc /proc \
--dev /dev \
--tmpfs /tmp \
--ro-bind /lib64 /lib64 \
--ro-bind /usr/lib64 /usr/lib64 \
--ro-bind /usr/lib /usr/lib \
--ro-bind /etc/ld.so.cache /etc/ld.so.cache \
--ro-bind /usr/local/libexec/slskd /usr/local/libexec/slskd \
--ro-bind /usr/share/zoneinfo /usr/share/zoneinfo \
--chdir /usr/local/libexec/slskd \
/usr/local/libexec/slskd/slskd
log-type = buffer

Seems weird to my why dinit wouldn't support this. I don't want to write a super huge command on one line.

davmac314 commented 9 months ago

Seems weird to my why dinit wouldn't support this. I don't want to write a super huge command on one line.

This just hasn't come up before. I agree there's no real reason not to support it. In the meantime, using a shell script to start the service (via exec) is probably a usable workaround.