mirror of
https://git.sr.ht/~rjarry/aerc
synced 2025-02-22 23:23:57 +01:00

The + character is not part of the 'basic regular expressions' in BSD grep. Use -E to enable extended (modern) regular expressions. Also remove escaping. This makes the commit msg hook work on macOS 14.2. Signed-off-by: Maarten Aertsen <maarten@nlnetlabs.nl> Signed-off-by: Robin Jarry <robin@jarry.cc>
67 lines
1.5 KiB
Bash
Executable file
67 lines
1.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
tmp=$(mktemp)
|
|
trap "rm -f $tmp" EXIT
|
|
|
|
global_fail=0
|
|
|
|
cmd_scd_sed='s/^\*:([a-z][a-z -]*)\*.*/\1/p'
|
|
cmd_go_sed='/^func ([[:alnum:]][[:alnum:]]*) Aliases() \[\]string {$/{n;
|
|
s/", "/ /g;
|
|
s/.*return \[\]string{"\(.*\)"}/\1/p
|
|
}'
|
|
|
|
grep_color=
|
|
if echo . | grep --color . >/dev/null 2>&1; then
|
|
grep_color=--color
|
|
fi
|
|
|
|
fail=0
|
|
sed -nE "$cmd_scd_sed" doc/*.scd | tr ' ' '\n' > "$tmp"
|
|
for f in $(find commands -type f -name '*.go'); do
|
|
for cmd in $(sed -n "$cmd_go_sed" "$f"); do
|
|
if ! grep -qFx "$cmd" "$tmp"; then
|
|
grep -HnF $grep_color "\"$cmd\"" "$f"
|
|
fail=$((fail+1))
|
|
fi
|
|
done
|
|
done
|
|
|
|
if [ "$fail" -gt 0 ]; then
|
|
echo "error: $fail command(s) not documented in man pages" >&2
|
|
global_fail=1
|
|
fi
|
|
|
|
fail=0
|
|
sed -n "$cmd_go_sed" $(find commands -type f -name '*.go') | tr ' ' '\n' > "$tmp"
|
|
for f in doc/*.scd; do
|
|
for cmd in $(sed -nE "$cmd_scd_sed" "$f" | tr ' ' '\n' | sed '/^-/d;/^$/d'); do
|
|
if ! grep -qFx "$cmd" "$tmp"; then
|
|
grep -Hn $grep_color "^\\*:$cmd\\*" "$f"
|
|
fail=$((fail+1))
|
|
fi
|
|
done
|
|
done
|
|
|
|
if [ "$fail" -gt 0 ]; then
|
|
echo "error: $fail non-existent command(s) documented in man pages" >&2
|
|
global_fail=1
|
|
fi
|
|
|
|
fail=0
|
|
sed -nE 's/^\*([a-z][a-z-]*)\* = .*/\1/p' doc/*.scd > "$tmp"
|
|
for f in $(find config -type f -name '*.go'); do
|
|
for opt in $(sed -nE 's/.*`ini:"([a-z][a-z-]*)".*/\1/p' $f); do
|
|
if ! grep -qFx "$opt" "$tmp"; then
|
|
grep -HnF $grep_color "\"$opt\"" "$f"
|
|
fail=$((fail+1))
|
|
fi
|
|
done
|
|
done
|
|
|
|
if [ "$fail" -gt 0 ]; then
|
|
echo "error: $fail option(s) not documented in man pages" >&2
|
|
global_fail=1
|
|
fi
|
|
|
|
exit $global_fail
|