Skip to content

Conversation

@kojiromike
Copy link
Contributor

@kojiromike kojiromike commented Jul 1, 2025

Short description of what this resolves:

Fixes all shellcheck warnings when running with -oall (maximum strictness) across docker/openemr (7.0.4+), packages/standard, and utilities.

Changes proposed in this pull request:

Shell style improvements:

  • Quote variables to prevent word splitting (SC2086)
  • Use find -exec {} + instead of find -print0 | xargs -0
  • Use arithmetic syntax (( )) instead of [ ] for numeric comparisons
  • Use single = in [[ ]] tests instead of ==
  • Use single quotes for literal strings
  • Use mkdir -p instead of [[ ! -d ]] && mkdir
  • Use POSIX parameter expansion for optional args: ${VAR:+-flag} ${VAR:+"$VAR"}
  • Use : instead of true for no-op commands
  • Use echo for simple strings, printf only when format specifiers needed
  • Replace manual ANSI escapes with tput

Bug fixes:

  • Fix misplaced quote in chown command (7.0.4, 8.0.0 devtoolsLibrary.source)

Legitimate shellcheck disables with comments:

AI disclosure:

  • Yes, I used AI to help with this PR

@jesdynf
Copy link
Collaborator

jesdynf commented Jul 2, 2025

@bradymiller I don't think this is exceptional and I've spot-checked it (and tested things on the commandline until I got what it was trying to get across) but it touches every script we own. Is there anything you want to peek at it before we let it through?


#run auto_configure
php auto_configure.php -c auto_configure.ini -f ${CONFIGURATION} || return 1
php auto_configure.php -c auto_configure.ini -f "${CONFIGURATION}" || return 1
Copy link
Member

Choose a reason for hiding this comment

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

Will this require this change (both for 7.0.3 and 7.0.4) if not already there:

// Collect parameters(if exist) for installation configuration settings
for ($i=1; $i < count($argv); $i++) {
if ($argv[$i] == '-f' && isset($argv[$i+1])) {
// Handle case where a single string contains all parameters
$configString = $argv[$i+1];
$configPairs = preg_split('/\s+/', trim($configString));
foreach ($configPairs as $pair) {
if (strpos($pair, '=') !== false) {
list($index, $value) = explode('=', $pair, 2);
$installSettings[$index] = $value;
}
}
// Skip the next argument since we already processed it
$i++;
} else {
// Handle standard key=value parameters
$indexandvalue = explode("=", $argv[$i]);
$index = $indexandvalue[0];
$value = $indexandvalue[1] ?? '';
$installSettings[$index] = $value;
}
}

@kojiromike kojiromike changed the title fix(shell): SC2086 auto apply fix(shell): all remaining shellcheck issues Jul 18, 2025
@kojiromike
Copy link
Contributor Author

bah, there was a bug in my git ls-files and this didn't actually catch all the shellcheck issues. There are still a ton in the xbackup scripts.

@jesdynf
Copy link
Collaborator

jesdynf commented Jul 18, 2025

Those might not be worth fighting. I need to migrate away from the current MySQL image with Percona's XtraBackup stuff to something with MariaDB.

@jesdynf
Copy link
Collaborator

jesdynf commented Jan 8, 2026

@kojiromike I've migrated off the xbackup stuff, which was blocking you, but this pull is aging -- should we close or can we move on it?

@kojiromike
Copy link
Contributor Author

I'll move on it soon.

@kojiromike kojiromike force-pushed the sc2086 branch 6 times, most recently from 8d87f0f to d2d3ae4 Compare January 8, 2026 05:06
Changes across docker/openemr (7.0.4, 7.0.5, 8.0.0, binary, flex),
packages/standard, and utilities:

Shell style improvements:
- Quote variables to prevent word splitting (SC2086)
- Use `find -exec {} +` instead of `find -print0 | xargs -0`
- Use arithmetic syntax `(( ))` instead of `[ ]` for numeric comparisons
- Use single `=` in `[[ ]]` tests instead of `==`
- Use single quotes for literal strings
- Use `mkdir -p` instead of `[[ ! -d ]] && mkdir`
- Use POSIX parameter expansion for optional args: `${VAR:+-flag} ${VAR:+"$VAR"}`
- Use `:` instead of `true` for no-op commands
- Use `echo` for simple strings, `printf` only when format specifiers needed
- Replace manual ANSI escapes with tput

Bug fixes:
- Fix misplaced quote in chown command (7.0.4, 8.0.0 devtoolsLibrary.source)

Legitimate shellcheck disables with comments:
- SC2086: CONFIGURATION variable intentionally word-splits
- SC2154: Variables passed as environment variables to container
- SC2310: Functions in retry loops with set -e are intentional
- SC2016: Literal $ in warning messages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@kojiromike kojiromike marked this pull request as ready for review January 8, 2026 05:12
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.

3 participants