Skip to content

Commit dfd9e81

Browse files
Lagrang3rustyrussell
authored andcommitted
lightning-cli: fix the access to man pages
Changelog-Fixed: lightning-cli: access to man pages from the installed directory. Signed-off-by: Lagrang3 <[email protected]>
1 parent 37150c1 commit dfd9e81

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cli/lightning-cli.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ try_exec_man (const char *page, char *relative_to) {
294294
case 0:
295295
/* child, run man command. */
296296
if (relative_to != NULL) {
297-
page = tal_fmt(page, "%s/../doc/%s.7", relative_to, page);
297+
page = tal_fmt(page, "%s/%s.7", relative_to, page);
298298
execlp("man", "man", "-l", page, (char *)NULL);
299299
}
300300
else {
@@ -701,12 +701,18 @@ int main(int argc, char *argv[])
701701
command = argv[2];
702702
char *page = tal_fmt(ctx, "lightning-%s", command);
703703

704+
/* Try to find the page in the MANPATH and PATH. */
704705
try_exec_man(page, NULL);
705706

706707
/* Try to find the page relative to this executable.
707708
* This handles the common scenario where lightning-cli
708709
* was built from source and hasn't been installed yet */
709-
try_exec_man(page, dirname(argv[0]));
710+
const char *dir = dirname(argv[0]);
711+
try_exec_man(page, tal_fmt(page, "%s/../doc", dir));
712+
713+
/* Try to find the page relative to this executable, but in the
714+
* install directory hierarchy. */
715+
try_exec_man(page, tal_fmt(page, "%s/../share/man/man7", dir));
710716

711717
tal_free(page);
712718
}

0 commit comments

Comments
 (0)