Skip to content

Comments

🧪 [testing improvement] Lint shell scripts with ShellCheck#118

Open
keeganwitt wants to merge 1 commit intogroovy:masterfrom
keeganwitt:lint-shell-scripts-2118990849023491486
Open

🧪 [testing improvement] Lint shell scripts with ShellCheck#118
keeganwitt wants to merge 1 commit intogroovy:masterfrom
keeganwitt:lint-shell-scripts-2118990849023491486

Conversation

@keeganwitt
Copy link
Member

Identified and fixed several issues in generate-stackbrew-library.sh, update.sh, and test/run.sh to improve code quality and reliability.

Key changes:

  • In generate-stackbrew-library.sh:
    • Fixed a bug where the commit variable was overwritten inside a loop, potentially affecting subsequent iterations.
    • Replaced eval with mapfile for more robust and secure array population from jq output.
    • Replaced sed with Bash parameter expansion for more efficient trailing whitespace removal.
    • Added proper quoting for associative array indices and other variable expansions.
  • In update.sh:
    • Added stderr redirection to sed --version check for better compatibility.
  • In test/run.sh:
    • Added proper quoting and default values for positional parameters.
    • Quoted id -u command substitution.

These changes align the codebase with ShellCheck best practices and improve overall script robustness.

Identified and fixed several issues in `generate-stackbrew-library.sh`, `update.sh`, and `test/run.sh` to improve code quality and reliability.

Key changes:
- In `generate-stackbrew-library.sh`:
    - Fixed a bug where the `commit` variable was overwritten inside a loop, potentially affecting subsequent iterations.
    - Replaced `eval` with `mapfile` for more robust and secure array population from `jq` output.
    - Replaced `sed` with Bash parameter expansion for more efficient trailing whitespace removal.
    - Added proper quoting for associative array indices and other variable expansions.
- In `update.sh`:
    - Added stderr redirection to `sed --version` check for better compatibility.
- In `test/run.sh`:
    - Added proper quoting and default values for positional parameters.
    - Quoted `id -u` command substitution.

These changes align the codebase with ShellCheck best practices and improve overall script robustness.

Co-authored-by: keeganwitt <64612+keeganwitt@users.noreply.github.com>
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.

1 participant