Skip to content

Commit

Permalink
pinfo: fix showing of man pages
Browse files Browse the repository at this point in the history
To show a man page (e.g. when there is no info file) this program uses
`man -w -W <name>` but option `-W` is unsupported by our `man(1)`.

This results in:

    $ pinfo man
    man: BADARG: bad command line argument: -W man
    Error executing command 'man -w -W  man'

and the terminal is left in a broken state.

Fix by applying this PR: baszoetekouw/pinfo#36
  • Loading branch information
tornaria authored and leahneukirchen committed Nov 2, 2024
1 parent cbb6fc4 commit 1913f31
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
57 changes: 57 additions & 0 deletions srcpkgs/pinfo/patches/36.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
From 032dbfc4bf9ff45719de64d251244ab1307db17c Mon Sep 17 00:00:00 2001
From: "David H. Bronke" <[email protected]>
Date: Sun, 9 Jun 2024 12:12:05 +0200
Subject: [PATCH 1/2] Fall back to running man without -W since some
implementations don't allow that

Fixes #12.

Change courtesy of loreb: https://github.com/baszoetekouw/pinfo/issues/12#issuecomment-884322986
---
src/manual.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/manual.c b/src/manual.c
index 5f058ff..791df32 100644
--- a/src/manual.c
+++ b/src/manual.c
@@ -186,8 +186,14 @@ set_initial_history(char *name)
pathFile = popen(buf, "r");
if (fgets(buf, sizeof(buf), pathFile)==NULL)
{
- fprintf(stderr, "Error executing command '%s'\n", buf);
- exit(1);
+ /* Try without -W */
+ snprintf(buf, sizeof(buf), "man -w %s %s", ManOptions, name);
+ pathFile = popen(buf, "r");
+ if (fgets(buf, sizeof(buf), pathFile)==NULL)
+ {
+ fprintf(stderr, "Error executing command '%s'\n", buf);
+ exit(1);
+ }
}
pclose(pathFile);
/* buf will be of the form "/usr/share/man/man1/sleep.1.gz". We

From c3722aa478420b6671ed932503e06886e04d4287 Mon Sep 17 00:00:00 2001
From: "David H. Bronke" <[email protected]>
Date: Sat, 29 Jun 2024 14:55:46 +0200
Subject: [PATCH 2/2] fix(src/manual.c): close pathFile before reopening

Suggested by @xaizek
---
src/manual.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/manual.c b/src/manual.c
index 791df32..bb730ee 100644
--- a/src/manual.c
+++ b/src/manual.c
@@ -186,6 +186,7 @@ set_initial_history(char *name)
pathFile = popen(buf, "r");
if (fgets(buf, sizeof(buf), pathFile)==NULL)
{
+ pclose(pathFile);
/* Try without -W */
snprintf(buf, sizeof(buf), "man -w %s %s", ManOptions, name);
pathFile = popen(buf, "r");
2 changes: 1 addition & 1 deletion srcpkgs/pinfo/template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Template file for 'pinfo'
pkgname=pinfo
version=0.6.13
revision=2
revision=3
build_style=gnu-configure
hostmakedepends="automake gettext gettext-devel tar texinfo"
makedepends="ncurses-devel"
Expand Down

0 comments on commit 1913f31

Please sign in to comment.