1
0
Fork 0
mirror of https://github.com/lightning/bolts.git synced 2025-03-10 17:18:44 +01:00
lightning-bolts/tools/spellcheck.sh
Rusty Russell 01571c1e58 Bolt 11: Invoice Protocol for Lightning Payments (#183)
This specifies a draft invoice protocol for lightning payments.

Particular thanks for detailed feedback from:
* ZmnSCPxj <ZmnSCPxj@protonmail.com>
* @Saicere  
* @kallewoof
* @halseth 
* @cdecker 

Signed-off-by: Rusty Russell <rusty@blockstream.com>
2017-06-27 20:08:13 +09:30

78 lines
1.8 KiB
Bash
Executable file

#!/bin/sh
# spellcheck.sh
# by ZmnSCPxj
# Simple script to spellcheck files.
#
# ZmnSCPxj puts this script into the public domain.
set -e
# Check if dirname works.
if (test_dir=`dirname -- /` && test "X"$test_dir = "X/")
then
my_dirname=dirname
else
my_dirname=false
fi
# Find the path to this script.
# We assume sed works on most systems, since it's very old.
my_dir=`$my_dirname -- "$0" ||
echo X"$0" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# This script should be in the tools/ directory of the
# repository.
homedir="$my_dir"/..
if [ x"$1" = x"--check" ]; then
CHECK=1
shift
fi
for f
do
if [ -n "$CHECK" ]; then
# Eliminate the following:
# #-references eg. [Use of segwit](#use-of-segwit)
# quoted identifers eg. `htlc_id`
# field descriptions, eg. `* [`num_htlcs*64`:`htlc_signature]'
# indented field names, eg. ' `num_htlcs`: 0'
# lightning addresses, eg. `lnbc1qpvj6chq...`
# BIP 173 addresses, eg. `bc1qpvj6chq...`
# Short hex strings, eg '0x2bb038521914'
# long hex strings
# long base58 strings
WORDS=$(sed -e 's/\](#[-a-zA-Z0-9_]*)//g' \
-e 's/`[a-zA-Z0-9_]*`//g' \
-e 's/\* \[`[_a-z0-9*]\+`://g' \
-e 's/0x[a-fA-F0-9]\+//g' \
-e 's/[a-fA-F0-9]\{20,\}//g' \
-e 's/^ .*_htlcs//g' \
-e 's/ ln\(bc\|tb\)[0-9munp]*1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]\+//g' \
-e 's/ \(bc\|tb\)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]\+//g' \
-e 's/[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]\{20,\}//g' < $f | aspell -l en_US --home-dir ${homedir} list)
if [ -n "$WORDS" ]; then
echo Misspelled words in $f: $WORDS >&2
exit 1
fi
else
aspell -l en_US --home-dir ${homedir} -c $f
fi
done