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

confd parser review #443

Merged
merged 7 commits into from
Nov 16, 2019
Merged

confd parser review #443

merged 7 commits into from
Nov 16, 2019

Conversation

dywisor
Copy link
Contributor

@dywisor dywisor commented Nov 16, 2019

  • use str formatting (printf / sprintf) to improve readability
  • use named regexp capture groups for config line parsing
  • read only files / sym-to-file from CONF_DIR (ignore dirs / devices / ...)
  • minor stuff: eliminate redundant code, use outfile var

follow-up on #435

Use string formatting when writing debug messages,
should be more readable.
Don't process the input line twice.
Instead, use groups to capture the variable's name and value.

Since values may or may not be quoted, use individual groups
for each case,

* val_bare    -- value was not quoted
* val_dquoted -- value was inside double quotes ("")

where exactly one of these groups can be defined at any time.
Later on, pick the defined group with a "defined-or"-chain over all variants.
Setting "debug = 1" does not depend on whether the config
variable is already defined or not, so move it to the outer block.
* cmdline arguments
* names/values read by parse_configfile() are strings
@linrunner linrunner merged commit a041fab into linrunner:master Nov 16, 2019
@linrunner
Copy link
Owner

Thank you very much :-)

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

Successfully merging this pull request may close these issues.

2 participants