diff options
Diffstat (limited to '')
-rwxr-xr-x | scripts/assert-spelling.sh | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/scripts/assert-spelling.sh b/scripts/assert-spelling.sh index 615fddc..f4ab58e 100755 --- a/scripts/assert-spelling.sh +++ b/scripts/assert-spelling.sh @@ -1,12 +1,9 @@ -#!/usr/bin/env bash -set -Eeuo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")" -cd ../ +#!/bin/sh -eu export LANG=C.UTF-8 for DICT in scripts/spelling/*.txt; do - diff <(sort "$DICT") "$DICT" || { + sort "$DICT" | diff - "$DICT" || { echo "The $DICT dictionary is unsorted. To fix it, run:" >&2 echo " LANG=C.UTF-8 sort $DICT | sponge $DICT" >&2 exit 1 @@ -14,16 +11,18 @@ for DICT in scripts/spelling/*.txt; do done OUT="$(mktemp)" -shopt -s globstar jekyll build --future --trace -for f in _site/**/*.html; do - if ! grep -E '^_site/vendor/' <(echo "$f") > /dev/null; then +# shellcheck disable=2044 +for f in $(find _site -type f -name '*.html'); do + if ! echo "$f" | grep -E '^_site/vendor/' > /dev/null; then l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)" - hunspell -u3 -H -d "$l" -p <(cat scripts/spelling/international.txt "scripts/spelling/$l.txt") "$f" | tee -a "$OUT" + CURR_DICT="$(mktemp)" + cat scripts/spelling/international.txt "scripts/spelling/$l.txt" > "$CURR_DICT" + hunspell -u3 -H -d "$l" -p "$CURR_DICT" "$f" | tee -a "$OUT" fi done -if [[ -s "$OUT" ]]; then +if [ -s "$OUT" ]; then printf "\nvvv Mispelled words detected by hunspell.\n\n" cut -d\ -f2- < "$OUT" | sort | uniq printf "\n^^^\n" >&2 |