Skip to content

fix(run): use sed for _xml_escape to avoid bash ${//} backreference regression#19

Merged
fissible merged 2 commits intomainfrom
fix/xml-escape-bash-compat
Mar 25, 2026
Merged

fix(run): use sed for _xml_escape to avoid bash ${//} backreference regression#19
fissible merged 2 commits intomainfrom
fix/xml-escape-bash-compat

Conversation

@fissible
Copy link
Copy Markdown
Owner

@fissible fissible commented Mar 25, 2026

Summary

  • _xml_escape was using ${s//pat/rep} substitutions with HTML entities (\&, <, etc.) in the replacement strings
  • bash 5.0 changed backslash handling: \& became a literal \& instead of an escaped &, breaking \& → producing \& instead of &
  • bash 5.2 then added & as a backreference to the matched text, breaking the no-backslash form: ${s//</&lt;} expands & to <, yielding <lt;
  • No single ${//} form is correct across bash 3.2 / 5.0–5.1 / 5.2+

Fix: switch to sed with -e 's/&/\&amp;/g' etc. In sed, \& is POSIX-stable and always means a literal &; this is consistent across GNU and BSD sed on all platforms.

Test plan

  • test-run-internals.sh — all 40 assertions pass locally (was 35/40 in CI with 5 _xml_escape failures)
  • Full suite — 507/507 locally
  • CI green on Ubuntu (bash 5.1) — expected to fix the 5 failures from run #23532103272

🤖 Generated with Claude Code

fissible and others added 2 commits March 25, 2026 10:25
…egression

bash 5.0 made backslashes literal in ${//} replacements (breaking \&amp;),
and bash 5.2 added & as a backreference to matched text (breaking &amp; for
non-& patterns). No single ${//} form is correct across bash 3.2/5.0/5.2+.
sed's \& is POSIX-stable: always a literal &, always. Use sed -e chains
for portability on both GNU and BSD sed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
${TMPDIR%/} errors under set -u when TMPDIR is unset (CI on Ubuntu).
${TMPDIR:-/tmp} provides the default but preserves a trailing slash,
causing double-slash paths that mktemp returns verbatim but cd normalises,
breaking assert_eq on $PWD. Use a local var to apply both fixes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fissible fissible merged commit ab9b9f2 into main Mar 25, 2026
6 checks passed
fissible added a commit that referenced this pull request Mar 25, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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