Skip to content

fix: simplify div-counting regexes and remove redundant tr pipe in admin control panel install - #223

Merged
PDowney merged 3 commits into
masterfrom
copilot/remove-unnecessary-tr-command
May 1, 2026
Merged

PDowney merged 3 commits into
masterfrom
copilot/remove-unnecessary-tr-command

Conversation

Copilot AI commented May 1, 2026

Copy link
Copy Markdown
Contributor

Software Version Updates

Two issues in the Adminer block div-balance check in admin-control-panel-install.sh: overly complex regex patterns with unnecessary whitespace matchers, and a redundant tr -d '[:space:]' stage after wc -l.

Changed Versions

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

  • Regex simplification: <div[^>]*[[:space:]]*><div[^>]*> and </div[[:space:]]*></div>. The trailing [[:space:]]* before > matched nothing useful and could mask malformed tags.
  • Pipeline cleanup: Dropped | tr -d '[:space:]' from both counting lines — wc -l already emits a bare integer.

Version Diff

-open_div_count=$(printf '%s\n' "$adminer_block" | grep -Eo '<div[^>]*[[:space:]]*>' | wc -l | tr -d '[:space:]')
-close_div_count=$(printf '%s\n' "$adminer_block" | grep -Eo '</div[[:space:]]*>' | wc -l | tr -d '[:space:]')
+open_div_count=$(printf '%s\n' "$adminer_block" | grep -Eo '<div[^>]*>' | wc -l)
+close_div_count=$(printf '%s\n' "$adminer_block" | grep -Eo '</div>' | wc -l)

Verification Checklist

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

Notes

This is an automated pull request created by the software version checker workflow.
Please verify these versions are stable releases before merging.

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":"The `tr -d '[:space:]'` is unnecessary because `wc -l` already outputs a clean integer without surrounding whitespace. This adds complexity without benefit and could obscure issues if `wc -l` behavior changes. Remove the `tr` command from both div counting lines.","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@@ -93,8 +93,8 @@\n         adminer_block=\"$(\n             awk -v mode=\"extract\" \"$AWK_ADMINER_BLOCK_SCRIPT\" \"${CONTROL_PANEL_INDEX}\"\n         )\"\n-        open_div_count=$(printf '%s\\n' \"$adminer_block\" | grep -Eo '<div[^>]*[[:space:]]*>' | wc -l | tr -d '[:space:]')\n-        close_div_count=$(printf '%s\\n' \"$adminer_block\" | grep -Eo '</div[[:space:]]*>' | wc -l | tr -d '[:space:]')\n+        open_div_count=$(printf '%s\\n' \"$adminer_block\" | grep -Eo '<div[^>]*[[:space:]]*>' | wc -l)\n+        close_div_count=$(printf '%s\\n' \"$adminer_block\" | grep -Eo '</div[[:space:]]*>' | wc -l)\n         if [[ -n \"$adminer_block\" && \"$open_div_count\" -gt 0 && \"$open_div_count\" -eq \"$close_div_count\" ]]; then\n             tmp_index=\"$(mktemp \"${CONTROL_PANEL_INDEX}.tmp.XXXXXX\")\" || {\n                 echo \"Error: Failed to create temporary file for Adminer card removal.\" >&2\n"}]},{"message":"The regex patterns for counting div tags are inconsistent and potentially incorrect. Line 96 uses `<div[^>]*[[:space:]]*>` which matches optional whitespace before the closing `>`, but this doesn't match divs where whitespace appears elsewhere. Line 97 uses `</div[[:space:]]*>` which has the same issue. Both patterns should use `<div[^>]*>` and `</div>` respectively to match standard HTML tags. The current patterns may miss divs formatted as `<div id='x'>` (no space before >) or incorrectly count malformed tags.","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@@ -93,8 +93,8 @@\n         adminer_block=\"$(\n             awk -v mode=\"extract\" \"$AWK_ADMINER_BLOCK_SCRIPT\" \"${CONTROL_PANEL_INDEX}\"\n         )\"\n-        open_div_count=$(printf '%s\\n' \"$adminer_block\" | grep -Eo '<div[^>]*[[:space:]]*>' | wc -l | tr -d '[:space:]')\n-        close_div_count=$(printf '%s\\n' \"$adminer_block\" | grep -Eo '</div[[:space:]]*>' | wc -l | tr -d '[:space:]')\n+        open_div_count=$(printf '%s\\n' \"$adminer_block\" | grep -Eo '<div[^>]*>' | wc -l | tr -d '[:space:]')\n+        close_div_count=$(printf '%s\\n' \"$adminer_block\" | grep -Eo '</div>' | wc -l | tr -d '[:space:]')\n         if [[ -n \"$adminer_block\" && \"$open_div_count\" -gt 0 && \"$open_div_count\" -eq \"$close_div_count\" ]]; then\n             tmp_index=\"$(mktemp \"${CONTROL_PANEL_INDEX}.tmp.XXXXXX\")\" || {\n                 echo \"Error: Failed to create temporary file for Adminer card removal.\" >&2\n"}]}]

… control panel install

Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/9b6adbb4-3f0c-4b1d-b75f-3f5a70cde9c0

Co-authored-by: PDowney <11467177+PDowney@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove unnecessary tr command from admin control panel script fix: simplify div-counting regexes and remove redundant tr pipe in admin control panel install May 1, 2026
Copilot finished work on behalf of PDowney May 1, 2026 04:35
Copilot AI requested a review from PDowney May 1, 2026 04:35
Removed outdated section regarding admin control panel regex and pipeline cleanup.
@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 05:35
Copilot AI review requested due to automatic review settings May 1, 2026 05:35
@PDowney
PDowney merged commit 4ff0901 into master May 1, 2026
11 checks passed
@github-actions
github-actions Bot deleted the copilot/remove-unnecessary-tr-command branch May 1, 2026 05:35

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

This PR updates the Admin Control Panel installer’s Adminer-card removal guard to use simpler, more consistent <div>/</div> matching and to streamline the line-count pipelines used for balance checks.

Changes:

  • Simplified the opening <div ...> and closing </div> grep patterns used for div-counting.
  • Removed a redundant tr -d '[:space:]' stage after wc -l in both div-count pipelines.

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