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-08-26 22:21:42 -06:00
|
|
|
_q=$1
|
|
|
|
|
|
|
|
! [ -f "${_q:-.}/index.txt" ] || file=./${_q:-.}/index.txt
|
|
|
|
! [ -f "${_q:-.}.txt" ] || file=./${_q:-.}.txt
|
|
|
|
! [ -f "${_q:-:}" ] || file=./${_q:-.}
|
|
|
|
|
|
|
|
# Fallback to package READMEs.
|
|
|
|
# False positive, intended behavior.
|
|
|
|
# shellcheck disable=2046
|
|
|
|
[ "$file" ] || {
|
|
|
|
set -f
|
|
|
|
set +f -- $(kiss s "${_q##*/}")
|
|
|
|
file=${1:+"$1/README"}
|
|
|
|
}
|
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
|
2021-08-26 22:21:42 -06:00
|
|
|
set +f -- $(find . -name "${_q##*/}.txt")
|
2021-07-10 07:33:32 -06:00
|
|
|
file=$1
|
|
|
|
}
|
|
|
|
|
|
|
|
: "${file:=404.txt}"
|
|
|
|
|
|
|
|
cat <<EOF - "$file" | "${PAGER:-less}"
|
2021-08-26 22:21:42 -06:00
|
|
|
Reading ${file#./}
|
2021-07-10 07:33:32 -06:00
|
|
|
________________________________________________________________________________
|
|
|
|
|
2021-08-26 22:21:42 -06:00
|
|
|
|
2021-07-10 07:33:32 -06:00
|
|
|
EOF
|