aboutsummaryrefslogtreecommitdiff
path: root/make-man.sh
blob: 4ed233638f7830a90e398110274fb8d8f95d540b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

# This script is derives from the original, written for Obarun Linux distribution by Eric Vidal.
# The original is released under BSD Zero Clause licence (BSD0), and can be found at https://git.obarun.org/Obarun/66/-/blob/master/doc/make-man.sh?ref_type=heads.


man8='apkg revdep'

man5='apkg.conf'

for i in 5 8;do
    if [ ! -d doc/man/man${i} ]; then
       mkdir -p -m 0755 doc/man/man"${i}" || exit 1
    fi
done

for i in ${man5}; do
    lowdown -s -Tman doc/"${i}".md -o doc/man/man5/"${i}".5 || exit 1
    var=$( sed -n -e '/^.TH/p' < doc/man/man5/"${i}".5)
    var=$(printf '%s' "$var" | tr '7' '5')
    sed -i "s!^.TH.*!${var}!" doc/man/man5/"${i}".5 || exit 1
    sed -i '4,8d' doc/man/man5/"${i}".5 || exit 1
done

for i in ${man8}; do
    lowdown -s -Tman doc/"${i}".md -o doc/man/man8/"${i}".8 || exit 1
    var=$( sed -n -e '/^.TH/p' < doc/man/man8/"${i}".8)
    var=$(printf '%s' "$var" | tr '7' '8')
    sed -i "s!^.TH.*!${var}!" doc/man/man8/"${i}".8 || exit 1
    sed -i '4,8d' doc/man/man8/"${i}".8 || exit 1
done

exit 0