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

Follow ShellCheck's style guide for Bash scripts #3947

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

cbandy
Copy link
Member

@cbandy cbandy commented Jun 29, 2024

Recent versions of ShellCheck recommend using [[ in Bash scripts and || true to indicate when errors can be ignored. I like the built-in : for this purpose.

Checklist:

  • Have you added an explanation of what your changes do and why you'd like them to be included?
  • Have you updated or added documentation for the change, as applicable?
  • Have you tested your changes on all related environments with successful results, as applicable?
    • Have you added automated tests?

Type of Changes:

  • Other

What is the new behavior (if this is a feature change)?

Changes to container entrypoints cause rollouts.

Other Information:

See: https://github.com/koalaman/shellcheck/wiki/SC2292
See: https://github.com/koalaman/shellcheck/wiki/SC2312
See: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#colon

Recent versions of ShellCheck recommend using "[[" in Bash scripts.
Recent versions of ShellCheck recommend using "|| true" to indicate when
errors can be ignored. I like the built-in ":" for this purpose.

See: https://github.com/koalaman/shellcheck/wiki/SC2292
See: https://github.com/koalaman/shellcheck/wiki/SC2312
See: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#colon

// Abort when the PostgreSQL version installed in the image does not
// match the cluster spec.
`results 'postgres path' "$(command -v postgres)"`,
`results 'postgres version' "${postgres_version:=$(postgres --version)}"`,
`results 'postgres path' "$(command -v postgres ||:)"`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be checking earlier in this script that we have postgres on this container?

Copy link
Member Author

Choose a reason for hiding this comment

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

Most things above here are function declarations. The only calls ahead of this are printf and id, so seems early enough to me.

@cbandy cbandy merged commit dd4674c into CrunchyData:master Jul 2, 2024
13 checks passed
@cbandy cbandy deleted the shellcheck branch July 2, 2024 21:10
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.

None yet

3 participants