config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 6670bdd954c1c2da5197aa3027b590cbf139abcb
parent 5eed571dcd66cf7588f7829d2c3a90b87d90a89b
Author: Jacob R. Edwards <n/a>
Date:   Tue,  9 Nov 2021 14:19:30 -0800

Add man section selection scripts

Diffstat:
Alocal/bin/bin/mah | 14++++++++++++++
Alocal/bin/bin/xman | 14++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/local/bin/bin/mah b/local/bin/bin/mah @@ -0,0 +1,14 @@ +#!/usr/bin/awk -f +# Copyright 2021 Jacob R. Edwards +# Print only certain sections of a manual page. Multiple sections +# can be specified with (a|b|...) syntax. + +BEGIN { + p = "^" toupper(ARGV[1]) "$"; + delete ARGV; + ARGC = 0; # Should awk really segfault without this? Mine does. +} + +/^[A-Z]/ { pr = 0 } +match($0, p) { pr = 1 } +pr diff --git a/local/bin/bin/xman b/local/bin/bin/xman @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright 2021 Jacob R. Edwards +# Man and mah (man heading selection script) wrapper + +IFS=/ +for man in "$@" +do + set -- $man + case $# in + (1) man "$1" ;; + (2) man "$1" | mah "$2" ;; + (*) { echo 'Invalid number of arguments' 1>&2; exit 1; } + esac +done