diff options
Diffstat (limited to 'miscutils/man.c')
-rw-r--r-- | miscutils/man.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/miscutils/man.c b/miscutils/man.c index 429898643..0e0b1cba6 100644 --- a/miscutils/man.c +++ b/miscutils/man.c | |||
@@ -102,11 +102,12 @@ static int run_pipe(const char *pager, char *man_filename, int man, int level) | |||
102 | 102 | ||
103 | ordinary_manpage: | 103 | ordinary_manpage: |
104 | close(STDIN_FILENO); | 104 | close(STDIN_FILENO); |
105 | open_zipped(man_filename); /* guaranteed to use fd 0 (STDIN_FILENO) */ | 105 | open_zipped(man_filename, /*fail_if_not_compressed:*/ 0); /* guaranteed to use fd 0 (STDIN_FILENO) */ |
106 | /* "2>&1" is added so that nroff errors are shown in pager too. | 106 | /* "2>&1" is added so that nroff errors are shown in pager too. |
107 | * Otherwise it may show just empty screen */ | 107 | * Otherwise it may show just empty screen */ |
108 | cmd = xasprintf( | 108 | cmd = xasprintf( |
109 | man ? "gtbl | nroff -Tlatin1 -mandoc 2>&1 | %s" | 109 | /* replaced -Tlatin1 with -Tascii for non-UTF8 displays */ |
110 | man ? "gtbl | nroff -Tascii -mandoc 2>&1 | %s" | ||
110 | : "%s", | 111 | : "%s", |
111 | pager); | 112 | pager); |
112 | system(cmd); | 113 | system(cmd); |
@@ -150,7 +151,7 @@ int man_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
150 | int man_main(int argc UNUSED_PARAM, char **argv) | 151 | int man_main(int argc UNUSED_PARAM, char **argv) |
151 | { | 152 | { |
152 | parser_t *parser; | 153 | parser_t *parser; |
153 | const char *pager; | 154 | const char *pager = ENABLE_LESS ? "less" : "more"; |
154 | char **man_path_list; | 155 | char **man_path_list; |
155 | char *sec_list; | 156 | char *sec_list; |
156 | char *cur_path, *cur_sect; | 157 | char *cur_path, *cur_sect; |
@@ -171,12 +172,6 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
171 | man_path_list[0] = (char*)"/usr/man"; | 172 | man_path_list[0] = (char*)"/usr/man"; |
172 | else | 173 | else |
173 | count_mp++; | 174 | count_mp++; |
174 | pager = getenv("MANPAGER"); | ||
175 | if (!pager) { | ||
176 | pager = getenv("PAGER"); | ||
177 | if (!pager) | ||
178 | pager = "more"; | ||
179 | } | ||
180 | 175 | ||
181 | /* Parse man.conf[ig] or man_db.conf */ | 176 | /* Parse man.conf[ig] or man_db.conf */ |
182 | /* man version 1.6f uses man.config */ | 177 | /* man version 1.6f uses man.config */ |
@@ -190,6 +185,11 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
190 | while (config_read(parser, token, 2, 0, "# \t", PARSE_NORMAL)) { | 185 | while (config_read(parser, token, 2, 0, "# \t", PARSE_NORMAL)) { |
191 | if (!token[1]) | 186 | if (!token[1]) |
192 | continue; | 187 | continue; |
188 | if (strcmp("DEFINE", token[0]) == 0) { | ||
189 | if (strncmp("pager", token[1], 5) == 0) { | ||
190 | pager = xstrdup(skip_whitespace(token[1]) + 5); | ||
191 | } | ||
192 | } else | ||
193 | if (strcmp("MANDATORY_MANPATH"+10, token[0]) == 0 /* "MANPATH"? */ | 193 | if (strcmp("MANDATORY_MANPATH"+10, token[0]) == 0 /* "MANPATH"? */ |
194 | || strcmp("MANDATORY_MANPATH", token[0]) == 0 | 194 | || strcmp("MANDATORY_MANPATH", token[0]) == 0 |
195 | ) { | 195 | ) { |
@@ -234,6 +234,15 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
234 | } | 234 | } |
235 | config_close(parser); | 235 | config_close(parser); |
236 | 236 | ||
237 | { | ||
238 | /* environment overrides setting from man.config */ | ||
239 | char *env_pager = getenv("MANPAGER"); | ||
240 | if (!env_pager) | ||
241 | env_pager = getenv("PAGER"); | ||
242 | if (env_pager) | ||
243 | pager = env_pager; | ||
244 | } | ||
245 | |||
237 | not_found = 0; | 246 | not_found = 0; |
238 | do { /* for each argv[] */ | 247 | do { /* for each argv[] */ |
239 | int found = 0; | 248 | int found = 0; |