Skip to content

Commit 7788f13

Browse files
committed
fix cross-compatibility issues with the generate-readme.sh by replacing awk with sed
1 parent f5638e9 commit 7788f13

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scripts/generate-readme.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ for file in $(ls *.md | grep -v -i 'README.md' | sort); do
1919
number="${BASH_REMATCH[2]}"
2020
title="${BASH_REMATCH[5]}"
2121
level=$((${#hashes} - 1))
22-
indent=$(printf ' %.0s' $(seq 1 $((level * 2))))
22+
indent=$(printf '%*s' $((level * 2)) " ")
2323
anchor=$(echo "$number-$title" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd '[:alnum:]-')
2424
echo "${indent}- [$number. $title](./$file#$anchor)" >> "$INDEX_TMP"
2525
fi
2626
done < "$file"
2727
done
2828

29-
# Generate the new README content
30-
awk -v table_of_contents="$(cat $INDEX_TMP)" '{gsub(/\[table_of_contents\]/, table_of_contents)}1' "$TEMPLATE" > "$README_TMP"
29+
# Replace [table_of_contents] with generated index
30+
sed "/\[table_of_contents\]/{
31+
r $INDEX_TMP
32+
d
33+
}" "$TEMPLATE" > "$README_TMP"
3134

3235
if [[ "$1" == "--check" ]]; then
3336
if ! diff --color=auto -u "$OUTFILE" "$README_TMP"; then
@@ -46,4 +49,5 @@ elif [[ "$1" == "--bless" ]]; then
4649
else
4750
rm "$INDEX_TMP" "$README_TMP"
4851
echo -e "${GREEN}No changes made. Use --check to verify or --bless to update README.md.${NC}"
49-
fi
52+
fi
53+

0 commit comments

Comments
 (0)