Skip to content

refactor: replace non-standard heredoc pattern with standard variable assignment - #221

Merged
PDowney merged 3 commits into
masterfrom
copilot/fix-heredoc-variable-assignment
May 1, 2026
Merged

PDowney merged 3 commits into
masterfrom
copilot/fix-heredoc-variable-assignment

Conversation

Copilot AI commented May 1, 2026

Copy link
Copy Markdown
Contributor

Software Version Updates

Replaces a non-standard read -r -d '' VAR << 'EOF' || true heredoc assignment with the conventional VAR=$(cat << 'EOF' ... ) form in admin-control-panel-install.sh.

Changed Versions

scripts/install/tools/frontend/admin-control-panel-install.sh

  • Swapped read -r -d '' + || true trick for a straightforward command substitution heredoc
-    read -r -d '' AWK_ADMINER_BLOCK_SCRIPT << 'AWKEOF' || true
+    AWK_ADMINER_BLOCK_SCRIPT=$(cat << 'AWKEOF'
         BEGIN { in_block=0; depth=0 }
         ...
 AWKEOF
+)

Version Diff

- read -r -d '' AWK_ADMINER_BLOCK_SCRIPT << 'AWKEOF' || true
+ AWK_ADMINER_BLOCK_SCRIPT=$(cat << 'AWKEOF'
  ...
  AWKEOF
+ )

Verification Checklist

  • Version numbers are correctly formatted
  • Version numbers are stable releases (not beta/RC)
  • No syntax errors in variables file

Notes

Semantically equivalent change. The read -r -d '' pattern relies on the non-zero exit code of read being suppressed by || true, which is non-obvious and can confuse static analysis tools and readers alike. $(cat <<'EOF') is idiomatic and immediately readable.

Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"Using 'read -r -d \\\"\\\"' with '|| true' to assign a heredoc to a variable is a non-standard pattern that may confuse readers. Consider using a standard variable assignment with a heredoc or a function to improve readability and maintainability.","fixFiles":[{"filePath":"scripts/install/tools/frontend/admin-control-panel-install.sh","diff":"diff --git a/scripts/install/tools/frontend/admin-control-panel-install.sh b/scripts/install/tools/frontend/admin-control-panel-install.sh\n--- a/scripts/install/tools/frontend/admin-control-panel-install.sh\n+++ b/scripts/install/tools/frontend/admin-control-panel-install.sh\n@@ -46,7 +46,7 @@\n # Remove Adminer tool card if INSTALL_ADMINER=0\n if [[ \"${INSTALL_ADMINER}\" -eq 0 ]]; then\n     CONTROL_PANEL_INDEX=\"/var/www/admin/control-panel/index.html\"\n-    read -r -d '' AWK_ADMINER_BLOCK_SCRIPT << 'AWKEOF' || true\n+    AWK_ADMINER_BLOCK_SCRIPT=$(cat << 'AWKEOF'\n         BEGIN { in_block=0; depth=0 }\n         {\n             line=$0\n@@ -79,6 +79,7 @@\n             }\n         }\n AWKEOF\n+)\n     # NOTE: This sed range depends on the HTML structure of index.html:\n     #   - the Adminer card must be wrapped in a single <div ... id=\"adminer-tool\" ...> ... </div> block\n     #   - the opening <div> with id=\"adminer-tool\" and its matching closing </div> must each be on a single line\n"}]}]

Copilot AI changed the title [WIP] Fix heredoc variable assignment for better readability refactor: replace non-standard heredoc pattern with standard variable assignment May 1, 2026
Copilot finished work on behalf of PDowney May 1, 2026 02:24
Copilot AI requested a review from PDowney May 1, 2026 02:24
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@sonarqubecloud

sonarqubecloud Bot commented May 1, 2026

Copy link
Copy Markdown

@PDowney
PDowney marked this pull request as ready for review May 1, 2026 03:44
Copilot AI review requested due to automatic review settings May 1, 2026 03:44
@PDowney
PDowney merged commit 200228e into master May 1, 2026
10 checks passed
@github-actions
github-actions Bot deleted the copilot/fix-heredoc-variable-assignment branch May 1, 2026 03:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors admin-control-panel-install.sh to use a more idiomatic heredoc-to-variable assignment style for the embedded awk script used when removing the Adminer tool card from the control panel.

Changes:

  • Replaced read -r -d '' ... <<'EOF' || true heredoc assignment with VAR=$(cat <<'EOF' ... ) for improved readability.

if [[ "${INSTALL_ADMINER}" -eq 0 ]]; then
CONTROL_PANEL_INDEX="/var/www/admin/control-panel/index.html"
read -r -d '' AWK_ADMINER_BLOCK_SCRIPT << 'AWKEOF' || true
AWK_ADMINER_BLOCK_SCRIPT=$(cat << 'AWKEOF'

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

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

Project convention requires updating the root CHANGELOG.md whenever the codebase is modified (see .github/copilot-instructions.md:48-53). This PR changes an install script but doesn’t include a CHANGELOG entry; please add one describing the refactor.

Copilot uses AI. Check for mistakes.
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