From 787437106de9d8d8b49cd6be77e8e4d198646322 Mon Sep 17 00:00:00 2001 From: DTB Date: Mon, 30 Jan 2023 23:37:25 -0500 Subject: [PATCH] manual system --- manual/manual | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 manual/manual diff --git a/manual/manual b/manual/manual new file mode 100755 index 0000000..8b5c1bc --- /dev/null +++ b/manual/manual @@ -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