unos-repository

APK repository for unos
git clone git://git.finwo.net/misc/unos-repository
Log | Files | Refs | README

test_ascii.sh (1113B)


      1 #!/bin/sh
      2 set -eu
      3 HERE=$(cd "$(dirname "$0")" && pwd)
      4 ROOT=$(cd "${HERE}/../.." && pwd)
      5 
      6 echo "==> test_ascii: source and docs are pure ASCII"
      7 
      8 # Non-ASCII is forbidden in tracked source and markdown. No em-dashes (use --),
      9 # no arrows (use ->), no box-drawing (use |-- and `--), no curly quotes.
     10 # build/ is generated. Key material is excluded because it is base64 blobs
     11 # whose content we neither wrote nor control.
     12 cd "$ROOT"
     13 hits=$(git ls-files -z \
     14   ':!:build/**' \
     15   ':!:packages/unos-keys/files/**' \
     16   | xargs -0 grep -nIP '[^\x00-\x7F]' 2>/dev/null || true)
     17 
     18 if [ -n "$hits" ]; then
     19   echo "FAIL: non-ASCII bytes in tracked files:" >&2
     20   echo "$hits" >&2
     21   exit 1
     22 fi
     23 echo "PASS: no non-ASCII in tracked sources"
     24 
     25 # Untracked working-tree sources count too, otherwise new files sneak past.
     26 new=$(git ls-files -zo --exclude-standard \
     27   ':!:build/**' \
     28   ':!:packages/unos-keys/files/**' \
     29   | xargs -0 grep -nIP '[^\x00-\x7F]' 2>/dev/null || true)
     30 
     31 if [ -n "$new" ]; then
     32   echo "FAIL: non-ASCII bytes in untracked files:" >&2
     33   echo "$new" >&2
     34   exit 1
     35 fi
     36 echo "PASS: no non-ASCII in untracked sources"