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

[Feature Request] Allow inline comments #390

Open
lonix1 opened this issue May 12, 2021 · 3 comments
Open

[Feature Request] Allow inline comments #390

lonix1 opened this issue May 12, 2021 · 3 comments
Labels

Comments

@lonix1
Copy link

lonix1 commented May 12, 2021

This is allowed:

# do this because of reason foo
notifempty
# do this because of reason bar
create 640 root root

This is not allowed:

notifempty                     # do this because of reason foo
create 640 root root           # do this because of reason bar

The second form is just as common when documenting config files, and much neater to read and maintain.

Please consider supporting inline comments?

And... Thanks for this really great tool!

@kdudka
Copy link
Member

kdudka commented May 12, 2021

Thanks for the proposal. I have not checked whether we would be able to implement this while preserving sufficient compatibility with existing configuration files. Just let me highlight that logrotate is not the only program that does not support inline comments. See for example the syntax of Apache's configuration files: https://httpd.apache.org/docs/2.4/configuring.html#syntax

@cgzones
Copy link
Member

cgzones commented May 12, 2021

A starting point would be

diff --git a/config.c b/config.c
index 65b9262..1e9f3e7 100644
--- a/config.c
+++ b/config.c
@@ -161,7 +161,7 @@ static char *isolateLine(char **strt, char **buf, size_t length) {
 
     start = *strt;
     endtag = start;
-    while (endtag < max && *endtag != '\n') {
+    while (endtag < max && *endtag != '\n' && *endtag != '#') {
         endtag++;}
     if (max < endtag)
         return NULL;

One would need to take special attention about configuration directives possible taking # as part of a valid value:

compressoptions -#
olddir /var/my#log#dir/

and also within script definitions.
So some sort of quoting support might be necessary.

@lonix1
Copy link
Author

lonix1 commented May 12, 2021

@kdudka I'm not complaining, I think logrotate is great!!!

Yeah programs like apache don't do inline comments (though nginx does 😉 😉 😉).

Keep in mind that inline commenting is common because it's easier to read and neater, and I find it keeps git diffs cleaner.

@kdudka kdudka added the wishlist label Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants