Skip to content

scripts: Improve error handling, when parameters are missing#2854

Merged
casperklein merged 13 commits intodocker-mailserver:masterfrom
casperklein:follow-up-2849
Oct 29, 2022
Merged

scripts: Improve error handling, when parameters are missing#2854
casperklein merged 13 commits intodocker-mailserver:masterfrom
casperklein:follow-up-2849

Conversation

@casperklein
Copy link
Copy Markdown
Member

@casperklein casperklein commented Oct 23, 2022

Description

When parameters are missing (alias destination in that case), this error is shown:

./setup.sh alias add postmaster@office
/usr/local/bin/setup: line 119: 2: unbound variable

--- UNCHECKED ERROR
  - script    = ./setup.sh
  - function  = _main
  - command   = ${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" setup "${@}"
  - line      = 229
  - exit code = 1

This should not have happened. Please file a bug report.

This PR solves that, by showing the usage instead.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (non-breaking change that does improve existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • 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

@casperklein casperklein marked this pull request as ready for review October 23, 2022 03:16
@casperklein casperklein requested a review from a team October 23, 2022 03:16
polarathene
polarathene previously approved these changes Oct 23, 2022
Comment thread target/bin/addalias Outdated
polarathene
polarathene previously approved these changes Oct 24, 2022
polarathene
polarathene previously approved these changes Oct 25, 2022
Comment thread target/scripts/helpers/utils.sh Outdated
polarathene
polarathene previously approved these changes Oct 26, 2022
Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

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

Awesome 🎉


I will point out that while in the review page I see a few other files that could throw in:

_require_n_parameters_or_print_usage 1 "${@}"

Like excluderelaydomain and setquota, both still have the existing help handling and could be consistent with the other files changed here, but not too fussed either way 😅

@casperklein
Copy link
Copy Markdown
Member Author

and could be consistent with the other files changed here, but not too fussed either way 😅

Consistency FTW 🚀

You know, that I am not a fan of "get this merged" and providing a follow up in such cases 😆 Therefore: 1935bb0

@casperklein casperklein merged commit 897d84f into docker-mailserver:master Oct 29, 2022
@casperklein casperklein deleted the follow-up-2849 branch October 29, 2022 09:04
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.

3 participants