From 4338ab81636fc57c5ea1570d7fe3b3e93492412f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 7 Aug 2020 18:42:22 +0200 Subject: [PATCH] meson: fix build/man/{man,html} to support page redirects Commands like build/man/man journald.conf.d would show the installed man page (or an error if the page cannot be found in the global search path), and not the one in the build directory. If the man page is a redirect, or the .html is a symlink, resolve it, build the target, and show that. --- man/html.in | 11 ++++++++++- man/man.in | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/man/html.in b/man/html.in index b7e79841d0..23b77ebbb0 100755 --- a/man/html.in +++ b/man/html.in @@ -11,5 +11,14 @@ ninja -C "@BUILD_ROOT@" version.h target="man/$1.html" ninja -C "@BUILD_ROOT@" "$target" + +fullname="@BUILD_ROOT@/$target" +redirect="$(readlink "$fullname" 2>/dev/null)" +if [ -n "$redirect" ]; then + ninja -C "@BUILD_ROOT@" "man/$redirect" + + fullname="@BUILD_ROOT@/man/$redirect" +fi + set -x -exec xdg-open "@BUILD_ROOT@/$target" +exec xdg-open "$fullname" diff --git a/man/man.in b/man/man.in index fa6164b8de..12eb332ee0 100755 --- a/man/man.in +++ b/man/man.in @@ -16,4 +16,13 @@ if [ -z "$target" ]; then exit 1 fi ninja -C "@BUILD_ROOT@" "$target" -exec man "@BUILD_ROOT@/$target" + +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"