Skip to content

Fix all shellcheck warnings and add shellcheck to CI#146

Merged
GernotMaier merged 8 commits into
mainfrom
v492-dev18-shellcheck
May 31, 2026
Merged

Fix all shellcheck warnings and add shellcheck to CI#146
GernotMaier merged 8 commits into
mainfrom
v492-dev18-shellcheck

Conversation

@GernotMaier
Copy link
Copy Markdown
Member

Resolved all 292 shellcheck warnings (--severity=warning) across 82 shell scripts. Zero warnings remain.

Main fix categories:

  • SC2046 (106): Quote $(dirname "$0") expansions in command positions
  • SC2034 (66): Suppress or remove genuinely unused variables
  • SC2068 (15): Double-quote array expansions in for loops
  • SC2164 (15): Add || exit to cd calls
  • SC2178/SC2206/SC2128 (36): Fix array vs. string type mismatches
  • SC2145 (5): Fix string+array argument mixing; use ${arr[*]}
  • SC2166 (4): Replace -a/-o with && / || in [ ] tests
  • SC2207 (6): Replace arr=($(...)) with mapfile -t
  • SC2155 (4): Separate declare and assign
  • SC2071 (1): Replace < with -lt in numeric [[ ]] test
  • SC2048 (2): Replace $* with "$@"
  • SC2053 (2): Quote RHS of == in [[ ]]
  • SC1083 (2): Fix literal braces in awk (quoting issue)
  • SC2061 (1): Quote -name glob argument in find
  • SC2027 (3): Fix quoted concatenation
  • Plus SC2154, SC2120, SC2165, SC2167, SC3010, SC3014, SC2043

Add ShellCheck step to .github/workflows/CI.yml so all future PRs are checked automatically.

Resolved all 292 shellcheck warnings (--severity=warning) across 82
shell scripts. Zero warnings remain.

Main fix categories:
- SC2046 (106): Quote $(dirname "$0") expansions in command positions
- SC2034 (66): Suppress or remove genuinely unused variables
- SC2068 (15): Double-quote array expansions in for loops
- SC2164 (15): Add || exit to cd calls
- SC2178/SC2206/SC2128 (36): Fix array vs. string type mismatches
- SC2145 (5): Fix string+array argument mixing; use ${arr[*]}
- SC2166 (4): Replace -a/-o with && / || in [ ] tests
- SC2207 (6): Replace arr=($(...)) with mapfile -t
- SC2155 (4): Separate declare and assign
- SC2071 (1): Replace < with -lt in numeric [[ ]] test
- SC2048 (2): Replace $* with "$@"
- SC2053 (2): Quote RHS of == in [[ ]]
- SC1083 (2): Fix literal braces in awk (quoting issue)
- SC2061 (1): Quote -name glob argument in find
- SC2027 (3): Fix quoted concatenation
- Plus SC2154, SC2120, SC2165, SC2167, SC3010, SC3014, SC2043

Add ShellCheck step to .github/workflows/CI.yml so all future PRs
are checked automatically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@GernotMaier GernotMaier self-assigned this May 30, 2026
GernotMaier and others added 7 commits May 30, 2026 21:29
Resolved all 1339 shellcheck info-level issues across 116 shell scripts.
Zero issues remain at --severity=info.

Main fix categories:
- SC2086 (1259): Quote single-value variables; suppress intentional
  word-splits with inline disable comments
- SC2012 (26): Replace ls-based file discovery with find
- SC1091 (24): Add shellcheck source=/dev/null before sourced files
- SC2196 (11): Replace deprecated egrep with grep -E
- SC2153 (6): Fix variable name typos / suppress false positives
- SC2021 (4): Fix [A-z] character ranges to [A-Za-z]
- SC2162 (2): Add -r flag to read commands
- SC2231 (2): Quote expansions in case patterns
- SC2030/SC2031 (2): Fix subshell variable visibility bug in
  RUNLIST.whichRunsAreAtmosphere.sh
- SC2013 (1): Replace for-in-$(cat) with while read loop
- SC2269 (1): Remove self-assignment
- SC2329 (1): Fix always-true expression

Update CI to use --severity=info (stricter than the previous --severity=warning).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes all 292 ShellCheck warnings (severity=warning) across 82 shell scripts in the repository and adds a ShellCheck step to the CI workflow so future contributions are automatically checked. The bulk of changes are mechanical: quoting of word-splitting expansions, replacing backticks with $(...), replacing arr=($(...)) with mapfile -t, switching to arrays for option lists, replacing egrep/-a/-o with portable equivalents, and adding || exit after cd.

Changes:

  • Add ShellCheck job to .github/workflows/CI.yml running find scripts -name "*.sh" | xargs shellcheck --severity=info.
  • Quote variable expansions and command substitutions, modernize backtick syntax, and convert option strings to arrays for safe word-splitting.
  • Several latent fixes: variable renames in nested loops in IRF.merge_and_link_MC_datasets.sh, fix of undefined $OFILE (now $TABFILE) in IRF.lookup_table_parallel_sub.sh, removal of unused variables.

Reviewed changes

Copilot reviewed 121 out of 121 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.github/workflows/CI.yml Add ShellCheck step to CI.
scripts/ANALYSIS.*.sh, scripts/IRF.*.sh, scripts/SPANALYSIS.*.sh, scripts/RUNLIST.*.sh, scripts/UTILITY.*.sh, scripts/set_environment.sh Mechanical ShellCheck fixes (quoting, $(), arrays, || exit).
scripts/preprocessing/*.sh ShellCheck fixes plus minor refactors (e.g., print_dqm_string_from_runlist.sh removes a no-op outer loop).
scripts/db_scripts/*.sh Quote $EVNDISPSCRIPTS and $EVNDISPSYS in command paths; egrepgrep -E.
scripts/helper_scripts/*.sh ShellCheck fixes; convert option strings to arrays; IRF.lookup_table_parallel_sub.sh switches $OFILE.list (undefined) to $TABFILE.list; IRF.optimizeTMVAforGammaHadronSeparation_sub.sh adds an unexplained rm -f "${MVADIR}/rates.log".
scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh ShellCheck fixes plus removal of unused EBINMIN/EBINMAX loops and unused DISPBDT/ANATYPE block.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/RUNLIST.preprocessing.sh
@GernotMaier GernotMaier marked this pull request as ready for review May 31, 2026 10:48
Base automatically changed from v492-dev18 to main May 31, 2026 11:15
@GernotMaier GernotMaier merged commit 1623979 into main May 31, 2026
2 checks passed
@GernotMaier GernotMaier deleted the v492-dev18-shellcheck branch May 31, 2026 11:16
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