-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
cbb6fc4
commit 1913f31
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters