Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 1 | /* mini man implementation for busybox |
| 2 | * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com> |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 3 | * Licensed under GPLv2, see file LICENSE in this source tree. |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 6 | //usage:#define man_trivial_usage |
| 7 | //usage: "[-aw] [MANPAGE]..." |
| 8 | //usage:#define man_full_usage "\n\n" |
| 9 | //usage: "Format and display manual page\n" |
Denys Vlasenko | 6642676 | 2011-06-05 03:58:28 +0200 | [diff] [blame] | 10 | //usage: "\n -a Display all pages" |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 11 | //usage: "\n -w Show page locations" |
| 12 | |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 13 | #include "libbb.h" |
| 14 | |
| 15 | enum { |
| 16 | OPT_a = 1, /* all */ |
| 17 | OPT_w = 2, /* print path */ |
| 18 | }; |
| 19 | |
Denis Vlasenko | ce02b15 | 2008-06-27 22:05:21 +0000 | [diff] [blame] | 20 | /* This is what I see on my desktop system being executed: |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 21 | |
| 22 | ( |
| 23 | echo ".ll 12.4i" |
| 24 | echo ".nr LL 12.4i" |
| 25 | echo ".pl 1100i" |
| 26 | gunzip -c '/usr/man/man1/bzip2.1.gz' |
| 27 | echo ".\\\"" |
| 28 | echo ".pl \n(nlu+10" |
| 29 | ) | gtbl | nroff -Tlatin1 -mandoc | less |
| 30 | |
| 31 | */ |
| 32 | |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 33 | static int show_manpage(const char *pager, char *man_filename, int man, int level); |
| 34 | |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 35 | static int run_pipe(const char *pager, char *man_filename, int man, int level) |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 36 | { |
| 37 | char *cmd; |
| 38 | |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 39 | /* Prevent man page link loops */ |
| 40 | if (level > 10) |
| 41 | return 0; |
| 42 | |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 43 | if (access(man_filename, R_OK) != 0) |
| 44 | return 0; |
| 45 | |
| 46 | if (option_mask32 & OPT_w) { |
| 47 | puts(man_filename); |
| 48 | return 1; |
| 49 | } |
| 50 | |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 51 | if (man) { /* man page, not cat page */ |
Denis Vlasenko | e2a09de | 2008-08-05 14:15:19 +0000 | [diff] [blame] | 52 | /* Is this a link to another manpage? */ |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 53 | /* The link has the following on the first line: */ |
| 54 | /* ".so another_man_page" */ |
Denis Vlasenko | e2a09de | 2008-08-05 14:15:19 +0000 | [diff] [blame] | 55 | |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 56 | struct stat sb; |
| 57 | char *line; |
| 58 | char *linkname, *p; |
| 59 | |
| 60 | /* On my system: |
| 61 | * man1/genhostid.1.gz: 203 bytes - smallest real manpage |
| 62 | * man2/path_resolution.2.gz: 114 bytes - largest link |
| 63 | */ |
| 64 | xstat(man_filename, &sb); |
| 65 | if (sb.st_size > 300) /* err on the safe side */ |
| 66 | goto ordinary_manpage; |
| 67 | |
| 68 | line = xmalloc_open_zipped_read_close(man_filename, NULL); |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 69 | if (!line || !is_prefixed_with(line, ".so ")) { |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 70 | free(line); |
| 71 | goto ordinary_manpage; |
| 72 | } |
| 73 | /* Example: man2/path_resolution.2.gz contains |
| 74 | * ".so man7/path_resolution.7\n<junk>" |
| 75 | */ |
| 76 | *strchrnul(line, '\n') = '\0'; |
Denis Vlasenko | e2a09de | 2008-08-05 14:15:19 +0000 | [diff] [blame] | 77 | linkname = skip_whitespace(&line[4]); |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 78 | |
Denis Vlasenko | 22b0bd8 | 2008-08-05 13:45:22 +0000 | [diff] [blame] | 79 | /* If link has no slashes, we just replace man page name. |
| 80 | * If link has slashes (however many), we go back *once*. |
| 81 | * ".so zzz/ggg/page.3" does NOT go back two levels. */ |
| 82 | p = strrchr(man_filename, '/'); |
| 83 | if (!p) |
| 84 | goto ordinary_manpage; |
| 85 | *p = '\0'; |
| 86 | if (strchr(linkname, '/')) { |
| 87 | p = strrchr(man_filename, '/'); |
| 88 | if (!p) |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 89 | goto ordinary_manpage; |
Denis Vlasenko | 22b0bd8 | 2008-08-05 13:45:22 +0000 | [diff] [blame] | 90 | *p = '\0'; |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 91 | } |
Denis Vlasenko | 22b0bd8 | 2008-08-05 13:45:22 +0000 | [diff] [blame] | 92 | |
| 93 | /* Links do not have .gz extensions, even if manpage |
| 94 | * is compressed */ |
Denys Vlasenko | 5965507 | 2012-03-06 16:23:50 +0100 | [diff] [blame] | 95 | man_filename = xasprintf("%s/%s", man_filename, linkname); |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 96 | free(line); |
| 97 | /* Note: we leak "new" man_filename string as well... */ |
| 98 | if (show_manpage(pager, man_filename, man, level + 1)) |
| 99 | return 1; |
Denis Vlasenko | 22b0bd8 | 2008-08-05 13:45:22 +0000 | [diff] [blame] | 100 | /* else: show the link, it's better than nothing */ |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | ordinary_manpage: |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 104 | close(STDIN_FILENO); |
Denys Vlasenko | 640ce3d | 2014-02-02 02:06:38 +0100 | [diff] [blame] | 105 | open_zipped(man_filename, /*fail_if_not_compressed:*/ 0); /* guaranteed to use fd 0 (STDIN_FILENO) */ |
Denis Vlasenko | 4cbffc0 | 2008-07-04 21:58:00 +0000 | [diff] [blame] | 106 | /* "2>&1" is added so that nroff errors are shown in pager too. |
Denis Vlasenko | b75fe79 | 2008-06-27 22:31:07 +0000 | [diff] [blame] | 107 | * Otherwise it may show just empty screen */ |
Denis Vlasenko | f6efccc | 2008-07-05 08:50:08 +0000 | [diff] [blame] | 108 | cmd = xasprintf( |
Denys Vlasenko | 30f17e9 | 2014-03-03 15:13:37 +0100 | [diff] [blame] | 109 | /* replaced -Tlatin1 with -Tascii for non-UTF8 displays */ |
| 110 | man ? "gtbl | nroff -Tascii -mandoc 2>&1 | %s" |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 111 | : "%s", |
| 112 | pager); |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 113 | system(cmd); |
| 114 | free(cmd); |
| 115 | return 1; |
| 116 | } |
| 117 | |
Denys Vlasenko | 5965507 | 2012-03-06 16:23:50 +0100 | [diff] [blame] | 118 | /* man_filename is of the form "/dir/dir/dir/name.s" */ |
Denis Vlasenko | 540baf6 | 2008-08-05 13:16:18 +0000 | [diff] [blame] | 119 | static int show_manpage(const char *pager, char *man_filename, int man, int level) |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 120 | { |
Denys Vlasenko | 5965507 | 2012-03-06 16:23:50 +0100 | [diff] [blame] | 121 | #if SEAMLESS_COMPRESSION |
| 122 | /* We leak this allocation... */ |
| 123 | char *filename_with_zext = xasprintf("%s.lzma", man_filename); |
| 124 | char *ext = strrchr(filename_with_zext, '.') + 1; |
| 125 | #endif |
| 126 | |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 127 | #if ENABLE_FEATURE_SEAMLESS_LZMA |
Denys Vlasenko | 5965507 | 2012-03-06 16:23:50 +0100 | [diff] [blame] | 128 | if (run_pipe(pager, filename_with_zext, man, level)) |
| 129 | return 1; |
| 130 | #endif |
| 131 | #if ENABLE_FEATURE_SEAMLESS_XZ |
| 132 | strcpy(ext, "xz"); |
Denys Vlasenko | ba1d561 | 2012-06-08 10:22:05 +0200 | [diff] [blame] | 133 | if (run_pipe(pager, filename_with_zext, man, level)) |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 134 | return 1; |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 135 | #endif |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 136 | #if ENABLE_FEATURE_SEAMLESS_BZ2 |
Denys Vlasenko | 5965507 | 2012-03-06 16:23:50 +0100 | [diff] [blame] | 137 | strcpy(ext, "bz2"); |
Denys Vlasenko | ba1d561 | 2012-06-08 10:22:05 +0200 | [diff] [blame] | 138 | if (run_pipe(pager, filename_with_zext, man, level)) |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 139 | return 1; |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 140 | #endif |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 141 | #if ENABLE_FEATURE_SEAMLESS_GZ |
Denys Vlasenko | 5965507 | 2012-03-06 16:23:50 +0100 | [diff] [blame] | 142 | strcpy(ext, "gz"); |
Denys Vlasenko | ba1d561 | 2012-06-08 10:22:05 +0200 | [diff] [blame] | 143 | if (run_pipe(pager, filename_with_zext, man, level)) |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 144 | return 1; |
| 145 | #endif |
| 146 | |
Denys Vlasenko | ba1d561 | 2012-06-08 10:22:05 +0200 | [diff] [blame] | 147 | return run_pipe(pager, man_filename, man, level); |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 148 | } |
| 149 | |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 150 | static char **add_MANPATH(char **man_path_list, int *count_mp, char *path) |
| 151 | { |
| 152 | if (path) while (*path) { |
| 153 | char *next_path; |
| 154 | char **path_element; |
| 155 | |
| 156 | next_path = strchr(path, ':'); |
| 157 | if (next_path) { |
Denys Vlasenko | 476654c | 2014-11-30 19:39:58 +0100 | [diff] [blame] | 158 | if (next_path == path) /* "::"? */ |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 159 | goto next; |
Denys Vlasenko | 476654c | 2014-11-30 19:39:58 +0100 | [diff] [blame] | 160 | *next_path = '\0'; |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 161 | } |
| 162 | /* Do we already have path? */ |
| 163 | path_element = man_path_list; |
| 164 | if (path_element) while (*path_element) { |
| 165 | if (strcmp(*path_element, path) == 0) |
| 166 | goto skip; |
| 167 | path_element++; |
| 168 | } |
| 169 | man_path_list = xrealloc_vector(man_path_list, 4, *count_mp); |
| 170 | man_path_list[*count_mp] = xstrdup(path); |
| 171 | (*count_mp)++; |
| 172 | /* man_path_list is NULL terminated */ |
| 173 | /* man_path_list[*count_mp] = NULL; - xrealloc_vector did it */ |
| 174 | skip: |
| 175 | if (!next_path) |
| 176 | break; |
Denys Vlasenko | 476654c | 2014-11-30 19:39:58 +0100 | [diff] [blame] | 177 | /* "path" may be a result of getenv(), be nice and don't mangle it */ |
| 178 | *next_path = ':'; |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 179 | next: |
Denys Vlasenko | 476654c | 2014-11-30 19:39:58 +0100 | [diff] [blame] | 180 | path = next_path + 1; |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 181 | } |
| 182 | return man_path_list; |
| 183 | } |
| 184 | |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 185 | int man_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 186 | int man_main(int argc UNUSED_PARAM, char **argv) |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 187 | { |
Denis Vlasenko | 09aaf78 | 2008-07-20 17:41:30 +0000 | [diff] [blame] | 188 | parser_t *parser; |
John Spencer | ff65061 | 2014-01-22 15:31:10 +0100 | [diff] [blame] | 189 | const char *pager = ENABLE_LESS ? "less" : "more"; |
Denis Vlasenko | 50d068c | 2008-04-19 03:42:47 +0000 | [diff] [blame] | 190 | char *sec_list; |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 191 | char *cur_path, *cur_sect; |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 192 | char **man_path_list; |
| 193 | int count_mp; |
| 194 | int cur_mp; |
Denis Vlasenko | ce02b15 | 2008-06-27 22:05:21 +0000 | [diff] [blame] | 195 | int opt, not_found; |
Denis Vlasenko | 084266e | 2008-07-26 23:08:31 +0000 | [diff] [blame] | 196 | char *token[2]; |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 197 | |
| 198 | opt_complementary = "-1"; /* at least one argument */ |
| 199 | opt = getopt32(argv, "+aw"); |
| 200 | argv += optind; |
| 201 | |
John Spencer | d6ae4fb | 2013-08-25 17:38:25 -0400 | [diff] [blame] | 202 | sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 203 | |
Denis Vlasenko | a1e16c9 | 2008-09-14 21:30:35 +0000 | [diff] [blame] | 204 | count_mp = 0; |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 205 | man_path_list = add_MANPATH(NULL, &count_mp, |
| 206 | getenv("MANDATORY_MANPATH"+10) /* "MANPATH" */ |
| 207 | ); |
| 208 | if (!man_path_list) { |
| 209 | /* default, may be overridden by /etc/man.conf */ |
| 210 | man_path_list = xzalloc(2 * sizeof(man_path_list[0])); |
Denis Vlasenko | e357d2a | 2008-09-14 21:26:55 +0000 | [diff] [blame] | 211 | man_path_list[0] = (char*)"/usr/man"; |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 212 | /* count_mp stays 0. |
| 213 | * Thus, man.conf will overwrite man_path_list[0] |
| 214 | * if a path is defined there. |
| 215 | */ |
| 216 | } |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 217 | |
Denys Vlasenko | 9a1b260 | 2010-10-04 14:19:59 +0200 | [diff] [blame] | 218 | /* Parse man.conf[ig] or man_db.conf */ |
Denys Vlasenko | 0e1b626 | 2009-07-24 02:28:12 +0200 | [diff] [blame] | 219 | /* man version 1.6f uses man.config */ |
Denys Vlasenko | 9a1b260 | 2010-10-04 14:19:59 +0200 | [diff] [blame] | 220 | /* man-db implementation of man uses man_db.conf */ |
Denys Vlasenko | 0e1b626 | 2009-07-24 02:28:12 +0200 | [diff] [blame] | 221 | parser = config_open2("/etc/man.config", fopen_for_read); |
| 222 | if (!parser) |
| 223 | parser = config_open2("/etc/man.conf", fopen_for_read); |
Denys Vlasenko | 9a1b260 | 2010-10-04 14:19:59 +0200 | [diff] [blame] | 224 | if (!parser) |
| 225 | parser = config_open2("/etc/man_db.conf", fopen_for_read); |
Denys Vlasenko | 0e1b626 | 2009-07-24 02:28:12 +0200 | [diff] [blame] | 226 | |
Denis Vlasenko | 94d03f0 | 2008-07-26 23:16:33 +0000 | [diff] [blame] | 227 | while (config_read(parser, token, 2, 0, "# \t", PARSE_NORMAL)) { |
| 228 | if (!token[1]) |
| 229 | continue; |
John Spencer | ff65061 | 2014-01-22 15:31:10 +0100 | [diff] [blame] | 230 | if (strcmp("DEFINE", token[0]) == 0) { |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 231 | if (is_prefixed_with("pager", token[1])) { |
John Spencer | ff65061 | 2014-01-22 15:31:10 +0100 | [diff] [blame] | 232 | pager = xstrdup(skip_whitespace(token[1]) + 5); |
| 233 | } |
| 234 | } else |
Denys Vlasenko | 9a1b260 | 2010-10-04 14:19:59 +0200 | [diff] [blame] | 235 | if (strcmp("MANDATORY_MANPATH"+10, token[0]) == 0 /* "MANPATH"? */ |
| 236 | || strcmp("MANDATORY_MANPATH", token[0]) == 0 |
| 237 | ) { |
Denys Vlasenko | ee41094 | 2014-11-27 00:40:08 +0100 | [diff] [blame] | 238 | man_path_list = add_MANPATH(man_path_list, &count_mp, token[1]); |
Denis Vlasenko | 94d03f0 | 2008-07-26 23:16:33 +0000 | [diff] [blame] | 239 | } |
| 240 | if (strcmp("MANSECT", token[0]) == 0) { |
| 241 | free(sec_list); |
| 242 | sec_list = xstrdup(token[1]); |
| 243 | } |
| 244 | } |
| 245 | config_close(parser); |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 246 | |
John Spencer | ff65061 | 2014-01-22 15:31:10 +0100 | [diff] [blame] | 247 | { |
| 248 | /* environment overrides setting from man.config */ |
| 249 | char *env_pager = getenv("MANPAGER"); |
| 250 | if (!env_pager) |
| 251 | env_pager = getenv("PAGER"); |
| 252 | if (env_pager) |
| 253 | pager = env_pager; |
| 254 | } |
| 255 | |
Denis Vlasenko | ce02b15 | 2008-06-27 22:05:21 +0000 | [diff] [blame] | 256 | not_found = 0; |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 257 | do { /* for each argv[] */ |
Denis Vlasenko | ce02b15 | 2008-06-27 22:05:21 +0000 | [diff] [blame] | 258 | int found = 0; |
Denis Vlasenko | 50d068c | 2008-04-19 03:42:47 +0000 | [diff] [blame] | 259 | cur_mp = 0; |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 260 | |
| 261 | if (strchr(*argv, '/')) { |
| 262 | found = show_manpage(pager, *argv, /*man:*/ 1, 0); |
| 263 | goto check_found; |
| 264 | } |
Denis Vlasenko | 50d068c | 2008-04-19 03:42:47 +0000 | [diff] [blame] | 265 | while ((cur_path = man_path_list[cur_mp++]) != NULL) { |
| 266 | /* for each MANPATH */ |
Denis Vlasenko | e88bd2d | 2008-11-16 04:05:13 +0000 | [diff] [blame] | 267 | cur_sect = sec_list; |
| 268 | do { /* for each section */ |
| 269 | char *next_sect = strchrnul(cur_sect, ':'); |
| 270 | int sect_len = next_sect - cur_sect; |
| 271 | char *man_filename; |
| 272 | int cat0man1 = 0; |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 273 | |
Denis Vlasenko | e88bd2d | 2008-11-16 04:05:13 +0000 | [diff] [blame] | 274 | /* Search for cat, then man page */ |
| 275 | while (cat0man1 < 2) { |
| 276 | int found_here; |
Denys Vlasenko | 5965507 | 2012-03-06 16:23:50 +0100 | [diff] [blame] | 277 | man_filename = xasprintf("%s/%s%.*s/%s.%.*s", |
Denis Vlasenko | e88bd2d | 2008-11-16 04:05:13 +0000 | [diff] [blame] | 278 | cur_path, |
| 279 | "cat\0man" + (cat0man1 * 4), |
| 280 | sect_len, cur_sect, |
| 281 | *argv, |
| 282 | sect_len, cur_sect); |
| 283 | found_here = show_manpage(pager, man_filename, cat0man1, 0); |
| 284 | found |= found_here; |
| 285 | cat0man1 += found_here + 1; |
| 286 | free(man_filename); |
| 287 | } |
Denis Vlasenko | 4cbffc0 | 2008-07-04 21:58:00 +0000 | [diff] [blame] | 288 | |
Denis Vlasenko | e88bd2d | 2008-11-16 04:05:13 +0000 | [diff] [blame] | 289 | if (found && !(opt & OPT_a)) |
| 290 | goto next_arg; |
| 291 | cur_sect = next_sect; |
| 292 | while (*cur_sect == ':') |
| 293 | cur_sect++; |
| 294 | } while (*cur_sect); |
Denis Vlasenko | 50d068c | 2008-04-19 03:42:47 +0000 | [diff] [blame] | 295 | } |
Denis Vlasenko | 0e7f28d | 2008-08-05 15:28:05 +0000 | [diff] [blame] | 296 | check_found: |
Denis Vlasenko | ce02b15 | 2008-06-27 22:05:21 +0000 | [diff] [blame] | 297 | if (!found) { |
| 298 | bb_error_msg("no manual entry for '%s'", *argv); |
| 299 | not_found = 1; |
| 300 | } |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 301 | next_arg: |
| 302 | argv++; |
| 303 | } while (*argv); |
| 304 | |
Denis Vlasenko | ce02b15 | 2008-06-27 22:05:21 +0000 | [diff] [blame] | 305 | return not_found; |
Denis Vlasenko | ffa4499 | 2008-04-13 08:20:00 +0000 | [diff] [blame] | 306 | } |