Skip to content

Commit 2989328

Browse files
committed
fix(compat): use glob pattern instead of regex for code fence
Replace regex matching with glob pattern matching for code fence detection to avoid backtick escaping issues in Bash 3.0. Changed from: [[ "$line" =~ ^\`\`\` ]] To: [[ "$line" == '```'* ]] This is more reliable across all Bash versions.
1 parent ea2970a commit 2989328

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/doc.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ function bashunit::doc::print_asserts() {
1717

1818
# Patterns stored in variable for Bash 3.0 compatibility
1919
local _doc_pattern='^## ([A-Za-z0-9_]+)'
20-
local _code_fence_pattern='^\`\`\`'
2120
local line
2221
while IFS='' read -r line || [[ -n "$line" ]]; do
2322
if [[ $line =~ $_doc_pattern ]]; then
@@ -33,7 +32,9 @@ function bashunit::doc::print_asserts() {
3332
fi
3433

3534
if ((should_print)); then
36-
if [[ "$line" =~ $_code_fence_pattern ]]; then
35+
# Check for code fence using pattern matching instead of regex
36+
# Avoids backtick escaping issues in Bash 3.0
37+
if [[ "$line" == '```'* ]]; then
3738
echo "--------------"
3839
echo "$docstring"
3940
should_print=0

0 commit comments

Comments
 (0)