aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/appletlib.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index ad373ae1c..d2e5900b5 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -127,17 +127,19 @@ static const char packed_usage[] ALIGN1 = { PACKED_USAGE };
127void FAST_FUNC bb_show_usage(void) 127void FAST_FUNC bb_show_usage(void)
128{ 128{
129 if (ENABLE_SHOW_USAGE) { 129 if (ENABLE_SHOW_USAGE) {
130 ssize_t FAST_FUNC (*full_write_fn)(const char *) =
131 xfunc_error_retval ? full_write2_str : full_write1_str;
130#ifdef SINGLE_APPLET_STR 132#ifdef SINGLE_APPLET_STR
131 /* Imagine that this applet is "true". Dont link in printf! */ 133 /* Imagine that this applet is "true". Dont link in printf! */
132 const char *usage_string = unpack_usage_messages(); 134 const char *usage_string = unpack_usage_messages();
133 135
134 if (usage_string) { 136 if (usage_string) {
135 if (*usage_string == '\b') { 137 if (*usage_string == '\b') {
136 full_write2_str("No help available\n"); 138 full_write_fn("No help available\n");
137 } else { 139 } else {
138 full_write2_str("Usage: "SINGLE_APPLET_STR" "); 140 full_write_fn("Usage: "SINGLE_APPLET_STR" ");
139 full_write2_str(usage_string); 141 full_write_fn(usage_string);
140 full_write2_str("\n"); 142 full_write_fn("\n");
141 } 143 }
142 if (ENABLE_FEATURE_CLEAN_UP) 144 if (ENABLE_FEATURE_CLEAN_UP)
143 dealloc_usage_messages((char*)usage_string); 145 dealloc_usage_messages((char*)usage_string);
@@ -153,19 +155,19 @@ void FAST_FUNC bb_show_usage(void)
153 while (*p++) continue; 155 while (*p++) continue;
154 ap--; 156 ap--;
155 } 157 }
156 full_write2_str(bb_banner); 158 full_write_fn(bb_banner);
157 full_write2_str(" multi-call binary.\n"); /* common string */ 159 full_write_fn(" multi-call binary.\n"); /* common string */
158 if (*p == '\b') 160 if (*p == '\b')
159 full_write2_str("\nNo help available\n"); 161 full_write_fn("\nNo help available\n");
160 else { 162 else {
161 full_write2_str("\nUsage: "); 163 full_write_fn("\nUsage: ");
162 full_write2_str(applet_name); 164 full_write_fn(applet_name);
163 if (p[0]) { 165 if (p[0]) {
164 if (p[0] != '\n') 166 if (p[0] != '\n')
165 full_write2_str(" "); 167 full_write_fn(" ");
166 full_write2_str(p); 168 full_write_fn(p);
167 } 169 }
168 full_write2_str("\n"); 170 full_write_fn("\n");
169 } 171 }
170 if (ENABLE_FEATURE_CLEAN_UP) 172 if (ENABLE_FEATURE_CLEAN_UP)
171 dealloc_usage_messages((char*)usage_string); 173 dealloc_usage_messages((char*)usage_string);
@@ -268,8 +270,10 @@ void lbb_prepare(const char *applet
268 && !(ENABLE_TRUE && strcmp(applet_name, "true") == 0) 270 && !(ENABLE_TRUE && strcmp(applet_name, "true") == 0)
269 && !(ENABLE_FALSE && strcmp(applet_name, "false") == 0) 271 && !(ENABLE_FALSE && strcmp(applet_name, "false") == 0)
270 && !(ENABLE_ECHO && strcmp(applet_name, "echo") == 0) 272 && !(ENABLE_ECHO && strcmp(applet_name, "echo") == 0)
271 ) 273 ) {
274 xfunc_error_retval = 0;
272 bb_show_usage(); 275 bb_show_usage();
276 }
273 } 277 }
274#endif 278#endif
275} 279}