fix(run): use sed for _xml_escape to avoid bash ${//} backreference regression#19
Merged
fix(run): use sed for _xml_escape to avoid bash ${//} backreference regression#19
Conversation
…egression
bash 5.0 made backslashes literal in ${//} replacements (breaking \&),
and bash 5.2 added & as a backreference to matched text (breaking & 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
added a commit
that referenced
this pull request
Mar 25, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_xml_escapewas using${s//pat/rep}substitutions with HTML entities (\&,<, etc.) in the replacement strings\&became a literal\&instead of an escaped&, breaking\&→ producing\&instead of&&as a backreference to the matched text, breaking the no-backslash form:${s//</<}expands&to<, yielding<lt;${//}form is correct across bash 3.2 / 5.0–5.1 / 5.2+Fix: switch to
sedwith-e 's/&/\&/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_escapefailures)🤖 Generated with Claude Code