diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-27 22:05:21 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-27 22:05:21 +0000 |
commit | ce02b157beff1a8031595364c2fb654034e608b5 (patch) | |
tree | 1f989f643708cf37a4e86f3b02ceaa3c7be29bc3 /miscutils | |
parent | 55da0be405bf4246ceb644b17b91d2686a9f1399 (diff) | |
download | busybox-w32-ce02b157beff1a8031595364c2fb654034e608b5.tar.gz busybox-w32-ce02b157beff1a8031595364c2fb654034e608b5.tar.bz2 busybox-w32-ce02b157beff1a8031595364c2fb654034e608b5.zip |
man: mimic "no manual entry for 'bogus'" message and exitcode
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/man.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/miscutils/man.c b/miscutils/man.c index 278e5a336..020310677 100644 --- a/miscutils/man.c +++ b/miscutils/man.c | |||
@@ -10,7 +10,7 @@ enum { | |||
10 | OPT_w = 2, /* print path */ | 10 | OPT_w = 2, /* print path */ |
11 | }; | 11 | }; |
12 | 12 | ||
13 | /* This is what I see on my desktop system deing executed: | 13 | /* This is what I see on my desktop system being executed: |
14 | 14 | ||
15 | ( | 15 | ( |
16 | echo ".ll 12.4i" | 16 | echo ".ll 12.4i" |
@@ -74,7 +74,7 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
74 | char *cur_path, *cur_sect; | 74 | char *cur_path, *cur_sect; |
75 | char *line, *value; | 75 | char *line, *value; |
76 | int count_mp, alloc_mp, cur_mp; | 76 | int count_mp, alloc_mp, cur_mp; |
77 | int opt; | 77 | int opt, not_found; |
78 | 78 | ||
79 | opt_complementary = "-1"; /* at least one argument */ | 79 | opt_complementary = "-1"; /* at least one argument */ |
80 | opt = getopt32(argv, "+aw"); | 80 | opt = getopt32(argv, "+aw"); |
@@ -123,7 +123,9 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
123 | fclose(cf); | 123 | fclose(cf); |
124 | } | 124 | } |
125 | 125 | ||
126 | not_found = 0; | ||
126 | do { /* for each argv[] */ | 127 | do { /* for each argv[] */ |
128 | int found = 0; | ||
127 | cur_mp = 0; | 129 | cur_mp = 0; |
128 | while ((cur_path = man_path_list[cur_mp++]) != NULL) { | 130 | while ((cur_path = man_path_list[cur_mp++]) != NULL) { |
129 | /* for each MANPATH */ | 131 | /* for each MANPATH */ |
@@ -140,7 +142,7 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
140 | sect_len, cur_sect, | 142 | sect_len, cur_sect, |
141 | *argv, | 143 | *argv, |
142 | sect_len, cur_sect); | 144 | sect_len, cur_sect); |
143 | int found = show_manpage(pager, man_filename); | 145 | found |= show_manpage(pager, man_filename); |
144 | free(man_filename); | 146 | free(man_filename); |
145 | if (found && !(opt & OPT_a)) | 147 | if (found && !(opt & OPT_a)) |
146 | goto next_arg; | 148 | goto next_arg; |
@@ -153,9 +155,13 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
153 | cur_path++; | 155 | cur_path++; |
154 | } while (*cur_path); | 156 | } while (*cur_path); |
155 | } | 157 | } |
158 | if (!found) { | ||
159 | bb_error_msg("no manual entry for '%s'", *argv); | ||
160 | not_found = 1; | ||
161 | } | ||
156 | next_arg: | 162 | next_arg: |
157 | argv++; | 163 | argv++; |
158 | } while (*argv); | 164 | } while (*argv); |
159 | 165 | ||
160 | return EXIT_SUCCESS; | 166 | return not_found; |
161 | } | 167 | } |