Skip to content

chore: address shellcheck findings in xrecovery-final.sh #421

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kojiromike
Copy link
Contributor

Short description of what this resolves:

Address the issues uncovered by shellcheck in one set of (identical) files.

Changes proposed in this pull request:

  • Add quotes around variables to avoid accidental wordsplitting and glob expansion.
  • Add curly braces around variables for consistency and readability.
  • Combine touch to create two files.
  • Remove exit 0 to exit with the correct exit code
  • Use set -euo pipefail to catch errors earlier.

@jesdynf
Copy link
Collaborator

jesdynf commented May 4, 2025

I'm willing to approve this, but can you walk me through how to turn off the carping for unprotected echo statements? That's just being fiddly.

@kojiromike
Copy link
Contributor Author

can you walk me through how to turn off the carping for unprotected echo statements? That's just being fiddly.

shellcheck doesn't actually seem to care if you quote around echo statements if a variable is not involved. I did those myself, out of habit. I stand by it, though, because echo will have less surprising behavior if its argument is always quoted.

@jesdynf
Copy link
Collaborator

jesdynf commented May 8, 2025

I'd prefer not to accept the edits to the echo statements unless we come to a decision that that's a style change we're actually going to enforce going forward, and this minute I'm not planning to do that.

@kojiromike
Copy link
Contributor Author

Actually the script doesn't work correctly without the quotes. Here's one example from the script:

$ echo xrecovery-final: mysql must not be running, yet it is; aborting
xrecovery-final: mysql must not be running, yet it is
bash: aborting: command not found

It might be barely noticeable since the very next line is exit 1, but it is, in any case, clearly not what the code is intended to do.

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