Skip to content

Commit ea2970a

Browse files
committed
fix(compat): move regex pattern outside loop in doc.sh
Move _code_fence_pattern declaration outside the loop to prevent potential issues with local variable redeclaration in Bash 3.0. This fixes the assert documentation display tests.
1 parent 834bd32 commit ea2970a

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/doc.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ function bashunit::doc::print_asserts() {
1515
local fn=""
1616
local should_print=0
1717

18-
# Pattern stored in variable for Bash 3.0 compatibility
18+
# Patterns stored in variable for Bash 3.0 compatibility
1919
local _doc_pattern='^## ([A-Za-z0-9_]+)'
20+
local _code_fence_pattern='^\`\`\`'
2021
local line
2122
while IFS='' read -r line || [[ -n "$line" ]]; do
2223
if [[ $line =~ $_doc_pattern ]]; then
@@ -32,8 +33,6 @@ function bashunit::doc::print_asserts() {
3233
fi
3334

3435
if ((should_print)); then
35-
# Pattern stored in variable for Bash 3.0 compatibility
36-
local _code_fence_pattern='^\`\`\`'
3736
if [[ "$line" =~ $_code_fence_pattern ]]; then
3837
echo "--------------"
3938
echo "$docstring"

0 commit comments

Comments
 (0)