From 993bea5ba056f52c0d4de7e52f0984b8b74acb5c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 27 Aug 2021 07:21:42 +0300 Subject: [PATCH] kiss-help: Expand to displaying README files within repositories --- contrib/kiss-help | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/contrib/kiss-help b/contrib/kiss-help index 5ae5aec..d0e08c5 100755 --- a/contrib/kiss-help +++ b/contrib/kiss-help @@ -6,23 +6,35 @@ cd "$KISS_ROOT/usr/share/doc/kiss" 2>/dev/null || { exit 1 } -! [ -f "${1:-.}/index.txt" ] || file=./${1:-.}/index.txt -! [ -f "${1:-.}.txt" ] || file=./${1:-.}.txt -! [ -f "${1:-:}" ] || file=./${1:-.} +_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"} +} # 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") + set +f -- $(find . -name "${_q##*/}.txt") file=$1 } : "${file:=404.txt}" cat <