Skip to content

Commit c8313c4

Browse files
committed
fix(coverage): use sed for html_escape cross-version bash compatibility
1 parent 386a509 commit c8313c4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/coverage.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,10 @@ function bashunit::coverage::check_threshold() {
728728
}
729729

730730
# Escape HTML special characters
731+
# Uses sed for cross-version bash compatibility (bash 3.2 vs 4.4+ handle & differently in replacement strings)
731732
function bashunit::coverage::html_escape() {
732733
local text="$1"
733-
text="${text//&/&}"
734-
text="${text//</&lt;}"
735-
text="${text//>/&gt;}"
736-
echo "$text"
734+
printf "%s" "$text" | sed "s/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g"
737735
}
738736

739737
# Convert file path to safe filename for HTML

0 commit comments

Comments
 (0)