1
0

manual system

This commit is contained in:
dtb 2023-01-30 23:37:25 -05:00
parent fd9ef9dcd1
commit 787437106d

37
manual/manual Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
set -e
str isvalue "$MANUAL_DIR" \
|| MANUAL_DIR=/usr/manual
argv0="$0"
! str isvalue "$1" || str isvalue "$3" \
&& printf "Usage: %s [name] (section)\n" "$argv0" 1>&2 \
&& exit 1 \
|| true
str isvalue "$2" && ! test -e "$MANUAL_DIR/$2/$1" \
&& printf "%s: %s: No manual entry in section %s\n" "$0" "$1" "$2" \
1>&2 \
&& exit 1 \
|| true
str isvalue "$2" \
&& PAGE="$MANUAL_DIR/$2/$1" \
|| for d in "$MANUAL_DIR"/*
do test -e "$d/$1" && PAGE="$d/$1"
done
! str isvalue "$PAGE" \
&& printf "%s: %s: No manual entry\n" "$0" "$1" 1>&2 \
&& exit 1 \
|| true
! str isvalue "$SECTION_DIR" \
&& printf "%s: %s: No manual entry\n" "$argv0" "$1" 1>&2 \
&& exit 1 \
|| true
<"$PAGE" groff -t -e -mandoc -Tascii