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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(listmailuser): Don't parse comments when reading config #2617

Conversation

polarathene
Copy link
Member

@polarathene polarathene commented Jun 4, 2022

Description

The quota support method dovecot_quota_to_hr() was failing when provided comment lines. Fixed by stripping them from the config used as input for the while loop.


Not sure how useful a test is for this? (we do have some tests that detect if other commands work without parsing failures though) Probably don't need a test for this as failure impact is UX only? This provides basis of consistent/improved config parsing to avoid issue in general going forward.

Resolved concern

I haven't looked over the difference for the shell syntax for passing the input data to the while loop, but it seems the 2nd commit syntax looks more appropriate? I'm just referencing usage elsewhere in the project, so happy for @georglauterbach or @casperklein to weigh in on what is suitable 馃憤

done <<< "$(_config_without_comments "${DATABASE}")"
# vs (latest commit):
done < <(_config_without_comments "${DATABASE}")

sed usage variants (for _config_without_comments()):

sed -n -r '/^\s*[^#[:space:]]/p' "${1}"
# vs (latest commit):
sed '/^[[:space:]]*#/d' "${1}"

# another usage in project is (not sure what the '|| true' is for):
grep -v "^\s*$\|^\s*\#" || true
# and another:
grep -vE '^(\s*$|#)'

EDIT: Whoops, noticed that the patterns aren't equivalent matching (empty line, white-space only, comments) 馃槄

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@georglauterbach

This comment was marked as resolved.

georglauterbach
georglauterbach previously approved these changes Jun 4, 2022
@georglauterbach georglauterbach requested a review from a team June 4, 2022 08:55
@polarathene

This comment was marked as resolved.

@polarathene
Copy link
Member Author

I need this PR and it's follow-up merged before I can continue #2615

I'm hoping another maintainer will have some time soon to spare, otherwise it's going to add friction to getting these PRs ready while I have time to spare 馃槄

Avoids passing comments to `dovecot_quota_to_hr()` which fails to handle it and would throws errors.
I'm not sure if it's better for the input, but the `sed` syntax is better. Instead of matching non-comments to print, it strips out lines that are comments.
Copy link
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤馃徏

target/scripts/helpers/utils.sh Show resolved Hide resolved
@polarathene polarathene merged commit 1f3e672 into docker-mailserver:master Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants