aboutsummaryrefslogtreecommitdiff
path: root/aux/workflow/assert-spelling.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-04-01 22:25:46 -0300
committerEuAndreh <eu@euandre.org>2023-04-01 22:26:11 -0300
commit76e1a0925fde2cbf25b75409cd353e20b9cfef48 (patch)
treecc6c3bd8ec0b182011377a20ace0b10f55fd86b5 /aux/workflow/assert-spelling.sh
parentRevamp CI: simpler variant of the same functionality (diff)
downloadremembering-76e1a0925fde2cbf25b75409cd353e20b9cfef48.tar.gz
remembering-76e1a0925fde2cbf25b75409cd353e20b9cfef48.tar.xz
Revamp code under aux/
Diffstat (limited to 'aux/workflow/assert-spelling.sh')
-rwxr-xr-xaux/workflow/assert-spelling.sh78
1 files changed, 0 insertions, 78 deletions
diff --git a/aux/workflow/assert-spelling.sh b/aux/workflow/assert-spelling.sh
deleted file mode 100755
index 853fd5e..0000000
--- a/aux/workflow/assert-spelling.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/sh
-set -eu
-
-. aux/lib.sh
-
-sort_dicts() {
- for f in po/spelling/*.txt; do
- if LANG=POSIX sort "$f" | diff - "$f"; then
- echo continue
- fi
- if [ "$IN_PLACE" = true ]; then
- OUT="$(mkstemp)"
- LANG=POSIX sort "$f" | uniq > "$OUT"
- mv "$OUT" "$f"
- else
- printf 'The %s dictionary is unsorted.' "$f" >&2
- printf " To fix it, run:\n" >&2
- printf " sh aux/workflow/assert-spelling.sh -i" >&2
- exit 1
- fi
- done
-}
-
-IN_PLACE=false
-while getopts 'l:i' flag; do
- case "$flag" in
- l)
- LANGS="$OPTARG"
- ;;
- i)
- IN_PLACE=true
- sort_dicts
- exit
- ;;
- *)
- exit 2
- ;;
- esac
-done
-shift $((OPTIND -1))
-
-assert_arg() {
- if [ -z "$1" ]; then
- echo "Missing $2" >&2
- exit 2
- fi
-}
-
-assert_arg "${LANGS:-}" '-l LANGS'
-
-mkdir -p po/spelling
-eval "touch po/spelling/{international,$(echo "$LANGS" | tr ' ' ,)}.txt"
-
-get_lang() {
- grep lang=.. "$1" |
- head -n1 |
- awk '
- match($0, /lang="(..)"/) {
- print substr($0, RSTART+length("lang=\""), 2)
- }
- '
-}
-
-ACC="$(mkstemp)"
-for f in "$@"; do
- l="$(get_lang "$f")"
- CURR_DICT="$(mkstemp)"
- cat po/spelling/international.txt "po/spelling/$l.txt" |
- sort | uniq > "$CURR_DICT"
- hunspell -u3 -H -d "$l" -p "$CURR_DICT" "$f" | tee -a "$ACC" >&2
-done
-
-if [ -s "$ACC" ]; then
- printf '\n\tMispelled words detected by hunspell above.\n\n' >&2
- exit 1
-fi
-
-sort_dicts