#!/bin/bash # Executes a UTS #35 rule file (e.g. collatz.txt) with ICU's stock command-line tool. # ./uts35.sh collatz.txt aaaaaaa # Collatz of 7, ends at Ma [ $# -eq 2 ] || { echo "usage: $0 RULES.txt dataword" >&2; exit 1; } RULES=$(cat "$1") || exit 1 UCONV=$(command -v uconv || echo /opt/homebrew/opt/icu4c/bin/uconv) # Homebrew's icu4c is keg-only [ -x "$UCONV" ] || { echo "uconv not found — apt install icu-devtools, or brew install icu4c" >&2; exit 1; } s="M$2" pass=0 printf '%3s - %s\n' 0 "$s" while true; do t=$(printf '%s' "$s" | "$UCONV" -f utf-8 -t utf-8 -x "$RULES") [ "$t" = "$s" ] && break s="$t" pass=$((pass + 1)) printf '%3s - %s\n' "$pass" "$s" done