elvish/tools/check-disallowed.sh
Qi Xiao fcc6d23f14 pkg/mods/doc: Convert links to language.html to absolute links.
For example, a link to language.html#number is converted to point to
https://elv.sh/ref/language.html#number instead. Such links are quite common in
elvdocs.

Also convert all link destinations that use ./language.html to use language.html
instead, and add a check in tools/check-disallowed.sh to ensure that remains the
case.
2023-01-02 01:35:41 +00:00

40 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# Check Go source files for disallowed content.
ret=0
# We have our own trimmed-down copy of net/rpc to reduce binary size. Make sure
# that dependency on net/rpc is not accidentally introduced.
x=$(find . -name '*.go' | xargs grep '"net/rpc"')
if test "$x" != ""; then
echo "======================================================================"
echo 'Disallowed import of net/rpc:'
echo "======================================================================"
echo "$x"
ret=1
fi
# The correct functioning of the unix: module depends on some certain calls not
# being made elsewhere.
x=$(find . -name '*.go' | egrep -v '\./pkg/(mods/unix|daemon|testutil)' |
xargs egrep 'unix\.(Umask|Getrlimit|Setrlimit)')
if test "$x" != ""; then
echo "======================================================================"
echo 'Disallowed call of unix.{Umask,Getrlimit,Setrlimit}:'
echo "======================================================================"
echo "$x"
ret=1
fi
# doc:show depends on references to language.html to not have a ./ prefix.
x=$(find . -name '*.elv' | xargs grep '(\.\/language\.html')
if test "$x" != ""; then
echo "======================================================================"
echo 'Disallowed use of ./ in link destination to language.html'
echo "======================================================================"
echo "$x"
ret=1
fi
exit $ret