From dfd9e815baff8974273fcc68731582277294132b Mon Sep 17 00:00:00 2001 From: Lagrang3 Date: Tue, 11 Feb 2025 11:54:02 +0100 Subject: [PATCH] lightning-cli: fix the access to man pages Changelog-Fixed: lightning-cli: access to man pages from the installed directory. Signed-off-by: Lagrang3 --- cli/lightning-cli.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/lightning-cli.c b/cli/lightning-cli.c index c3a25afd1..63ef94c5b 100644 --- a/cli/lightning-cli.c +++ b/cli/lightning-cli.c @@ -294,7 +294,7 @@ try_exec_man (const char *page, char *relative_to) { case 0: /* child, run man command. */ if (relative_to != NULL) { - page = tal_fmt(page, "%s/../doc/%s.7", relative_to, page); + page = tal_fmt(page, "%s/%s.7", relative_to, page); execlp("man", "man", "-l", page, (char *)NULL); } else { @@ -701,12 +701,18 @@ int main(int argc, char *argv[]) command = argv[2]; char *page = tal_fmt(ctx, "lightning-%s", command); + /* Try to find the page in the MANPATH and PATH. */ try_exec_man(page, NULL); /* Try to find the page relative to this executable. * This handles the common scenario where lightning-cli * was built from source and hasn't been installed yet */ - try_exec_man(page, dirname(argv[0])); + const char *dir = dirname(argv[0]); + try_exec_man(page, tal_fmt(page, "%s/../doc", dir)); + + /* Try to find the page relative to this executable, but in the + * install directory hierarchy. */ + try_exec_man(page, tal_fmt(page, "%s/../share/man/man7", dir)); tal_free(page); }