2019-05-09 19:23:50 +08:00
|
|
|
#!/bin/sh
|
2021-10-01 18:44:33 +08:00
|
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
|
2019-05-09 19:23:50 +08:00
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Use: $0 page-name (with no section suffix)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-01-27 16:10:25 +08:00
|
|
|
# make sure the rules have been regenerated (in case update-man-rules was just run)
|
2020-03-24 03:39:23 +08:00
|
|
|
ninja -C "@BUILD_ROOT@" version.h
|
|
|
|
|
2019-06-04 18:56:14 +08:00
|
|
|
page="$(echo "$1" | sed 's/\./\\./')"
|
|
|
|
target=$(ninja -C "@BUILD_ROOT@" -t query man/man | grep -E -m1 "man/$page\.[0-9]$" | awk '{print $2}')
|
2019-05-09 19:23:50 +08:00
|
|
|
if [ -z "$target" ]; then
|
|
|
|
echo "Cannot find page $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
ninja -C "@BUILD_ROOT@" "$target"
|
2020-08-08 00:42:22 +08:00
|
|
|
|
|
|
|
fullname="@BUILD_ROOT@/$target"
|
|
|
|
redirect="$(sed -n -r '1 s|^\.so man[0-9]/(.*)|\1|p' "$fullname")"
|
|
|
|
if [ -n "$redirect" ]; then
|
|
|
|
ninja -C "@BUILD_ROOT@" "man/$redirect"
|
|
|
|
|
|
|
|
fullname="@BUILD_ROOT@/man/$redirect"
|
|
|
|
fi
|
|
|
|
|
|
|
|
exec man "$fullname"
|