kiss/contrib/kiss-help

29 lines
708 B
Plaintext
Raw Normal View History

2021-07-10 07:33:32 -06:00
#!/bin/sh -e
2020-06-12 15:00:58 -06:00
# Read KISS documentation
cd "$KISS_ROOT/usr/share/doc/kiss" 2>/dev/null || {
printf 'Documentation is missing from /usr/share/doc/kiss\n'
exit 1
}
2021-07-10 07:33:32 -06:00
! [ -f "${1:-.}/index.txt" ] || file=./${1:-.}/index.txt
! [ -f "${1:-.}.txt" ] || file=./${1:-.}.txt
! [ -f "${1:-:}" ] || file=./${1:-.}
2020-06-12 15:00:58 -06:00
2021-07-10 07:33:32 -06:00
# Fallback to search (allows 'kiss help firefox' to work).
# False positive, intended behavior.
# shellcheck disable=2046
[ "$file" ] || {
set -f
set +f -- $(find . -name "${1##*/}.txt")
file=$1
}
: "${file:=404.txt}"
cat <<EOF - "$file" | "${PAGER:-less}"
Reading $PWD/${file#./}
________________________________________________________________________________
EOF