]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/man.in
Merge pull request #32677 from keszybz/wording-fixes
[thirdparty/systemd.git] / man / man.in
1 #!/bin/sh
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3
4 set -e
5
6 if [ -z "$1" ]; then
7 echo "Use: $0 page-name (with no section suffix)"
8 exit 1
9 fi
10
11 # make sure the rules have been regenerated (in case update-man-rules was just run)
12 ninja -C "@BUILD_ROOT@" version.h
13
14 page="$(echo "$1" | sed 's/\./\\./')"
15 target=$(ninja -C "@BUILD_ROOT@" -t query man/man | grep -E -m1 "man/$page\.[0-9]$" | awk '{print $2}')
16 if [ -z "$target" ]; then
17 echo "Cannot find page $1"
18 exit 1
19 fi
20 ninja -C "@BUILD_ROOT@" "$target"
21
22 fullname="@BUILD_ROOT@/$target"
23 redirect="$(sed -n -r '1 s|^\.so man[0-9]/(.*)|\1|p' "$fullname")"
24 if [ -n "$redirect" ]; then
25 ninja -C "@BUILD_ROOT@" "man/$redirect"
26
27 fullname="@BUILD_ROOT@/man/$redirect"
28 fi
29
30 exec man "$fullname"