Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow \ in .conf files to allow multiple lines for run/task/service #186

Closed
hongkongkiwi opened this issue Aug 18, 2021 · 5 comments
Closed
Assignees
Milestone

Comments

@hongkongkiwi
Copy link
Contributor

hongkongkiwi commented Aug 18, 2021

I saw that there is an open task for a new .svc format #148 which breaks the service up into multiline syntax.

Before this new format is implemented, I was wondering if it's possible to just allow \ to breakup lines (like in shell scripts). This would mean we could have multiline service definitions with minimal work.... e.g.

service [2345] \
env:-/etc/conf.d/gpsd \
-N -s $GPSD_SERIAL_SPEED -S $GPSD_PORT \
 -F "$GPSD_SOCK" -D $GPSD_DEBUG_LEVEL \
$GPSD_OPTIONS "$GPSD_DEVICE" \
-- GPS Daemon
@hongkongkiwi hongkongkiwi changed the title Allow \ in service,task,run names to allow multiple lines [Suggestion] Allow \ in service,task,run names to allow multiple lines Aug 19, 2021
@troglobit
Copy link
Owner

No, I'd much rather we implement the new format instead. There's just too much that can go wrong with this proposal, because I've actually tried once before.

@troglobit
Copy link
Owner

Since yesterday I've looked into this again, in part due to your comment in #148, but also because I've been hit by the problem of long lines myself the last six months ... I admit I was wrong for closing this, sorry.

Looking into the matter a bit further, I realized one of the libraries we use carry fparseln(), from NetBSD, which sort of exist for this very use-case.

Only downside is that it's a bit too competent, not only does it prune .conf lines starting with comment, it also drops comments trailing a line ... unless it's escaped. Nevertheless, I think fparseln() is the way forward here -- even though some uses may experience some regressions.

Our own test/initctl-status-subset.sh immediately caught the problem. It has the following services:

task manual:yes name:foo :1 serv -- Foo #1
task manual:yes name:foo :2 serv -- Foo #2
task manual:yes name:foo :3 serv -- Foo #3

The test fails since it cannot find any service with decription "Foo #1". However, escaping them works, so that needs to go into the documentation and ChangeLog for this upcoming release:

task manual:yes name:foo :1 serv -- Foo \#1
task manual:yes name:foo :2 serv -- Foo \#2
task manual:yes name:foo :3 serv -- Foo \#3

@troglobit troglobit changed the title [Suggestion] Allow \ in service,task,run names to allow multiple lines Allow \ in .conf files to allow multiple lines for run/task/service Nov 19, 2022
@troglobit troglobit added this to the 4.4 milestone Nov 19, 2022
@troglobit troglobit self-assigned this Nov 19, 2022
@troglobit
Copy link
Owner

There, fixed.

@hongkongkiwi
Copy link
Contributor Author

This is really helpful! Thank you.

Hmm yes, apart from comments and \ what other characters need escaping here?

@troglobit
Copy link
Owner

None, only \ has special meaning. The thing with # is that trailing comments was not supported before, but with the new implementation it is. So you need to escape \ and # only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants