man: mimic "no manual entry for 'bogus'" message and exitcode

This commit is contained in:
Denis Vlasenko 2008-06-27 22:05:21 +00:00
parent 55da0be405
commit ce02b157be

View File

@ -10,7 +10,7 @@ enum {
OPT_w = 2, /* print path */ OPT_w = 2, /* print path */
}; };
/* This is what I see on my desktop system deing executed: /* This is what I see on my desktop system being executed:
( (
echo ".ll 12.4i" echo ".ll 12.4i"
@ -74,7 +74,7 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv)
char *cur_path, *cur_sect; char *cur_path, *cur_sect;
char *line, *value; char *line, *value;
int count_mp, alloc_mp, cur_mp; int count_mp, alloc_mp, cur_mp;
int opt; int opt, not_found;
opt_complementary = "-1"; /* at least one argument */ opt_complementary = "-1"; /* at least one argument */
opt = getopt32(argv, "+aw"); opt = getopt32(argv, "+aw");
@ -123,7 +123,9 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv)
fclose(cf); fclose(cf);
} }
not_found = 0;
do { /* for each argv[] */ do { /* for each argv[] */
int found = 0;
cur_mp = 0; cur_mp = 0;
while ((cur_path = man_path_list[cur_mp++]) != NULL) { while ((cur_path = man_path_list[cur_mp++]) != NULL) {
/* for each MANPATH */ /* for each MANPATH */
@ -140,7 +142,7 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv)
sect_len, cur_sect, sect_len, cur_sect,
*argv, *argv,
sect_len, cur_sect); sect_len, cur_sect);
int found = show_manpage(pager, man_filename); found |= show_manpage(pager, man_filename);
free(man_filename); free(man_filename);
if (found && !(opt & OPT_a)) if (found && !(opt & OPT_a))
goto next_arg; goto next_arg;
@ -153,9 +155,13 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv)
cur_path++; cur_path++;
} while (*cur_path); } while (*cur_path);
} }
if (!found) {
bb_error_msg("no manual entry for '%s'", *argv);
not_found = 1;
}
next_arg: next_arg:
argv++; argv++;
} while (*argv); } while (*argv);
return EXIT_SUCCESS; return not_found;
} }