Skip to content

Commit a452a51

Browse files
fix(docs): make residual shortcode guard portable and fail on scan errors
1 parent 40f5e23 commit a452a51

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎scripts/sanitize-docs-emoji.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ find "$DOCS_DIR" -type f -name '*.mdx' -exec perl -0pi -e '
1717
s/:warning:/⚠️/g;
1818
' {} +
1919

20-
if matches="$(find "$DOCS_DIR" -type f -name '*.mdx' -exec grep -HnP '(?<![\w:]):[a-z][a-z0-9_+-]*:(?![\w:])' {} + || true)" && [[ -n "$matches" ]]; then
20+
# perl rather than grep -P so the guard also works on BSD/macOS; a scan error aborts via set -e.
21+
matches="$(find "$DOCS_DIR" -type f -name '*.mdx' -exec perl -ne '
22+
print "$ARGV:$.:$_" if /(?<![\w:]):[a-z][a-z0-9_+-]*:(?![\w:])/;
23+
close ARGV if eof;
24+
' {} +)"
25+
if [[ -n "$matches" ]]; then
2126
echo "unmapped emoji shortcodes remain under $DOCS_DIR, add them to this script:" >&2
2227
printf '%s\n' "$matches" >&2
2328
exit 1

0 commit comments

Comments
 (0)