summaryrefslogtreecommitdiff
path: root/man/man.in
blob: 75680b860c7a9faca10e543976a6fcaaa1c47766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
set -e

if [ -z "$1" ]; then
    echo "Use: $0 page-name (with no section suffix)"
    exit 1
fi

page="$(echo "$1" | sed 's/\./\\./')"
target=$(ninja -C "@BUILD_ROOT@" -t query man/man | grep -E -m1 "man/$page\.[0-9]$" | awk '{print $2}')
if [ -z "$target" ]; then
    echo "Cannot find page $1"
    exit 1
fi
ninja -C "@BUILD_ROOT@" "$target"
exec man "@BUILD_ROOT@/$target"