aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-09-11 16:35:14 -0500
committerRob Landley <rob@landley.net>2015-09-11 16:35:14 -0500
commite5354ca12a232b3f97726214254a868771cb70d1 (patch)
treeba373c24ede64b8a18f11a02cf834ce99aa586bf /lib/lib.c
parentd067571abb2b7934f3350c90ca891beb987c68fd (diff)
downloadtoybox-e5354ca12a232b3f97726214254a868771cb70d1.tar.gz
Replace toys.exithelp with help_exit() in lib.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/lib.c b/lib/lib.c
index c5fca3f7..9e0a3a52 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -13,10 +13,12 @@ void verror_msg(char *msg, int err, va_list va)
if (msg) vfprintf(stderr, msg, va);
else s+=2;
if (err) fprintf(stderr, s, strerror(err));
- putc('\n', stderr);
+ if (msg || err) putc('\n', stderr);
if (!toys.exitval) toys.exitval++;
}
+// These functions don't collapse together because of the va_stuff.
+
void error_msg(char *msg, ...)
{
va_list va;
@@ -40,7 +42,19 @@ void error_exit(char *msg, ...)
{
va_list va;
- if (CFG_TOYBOX_HELP && toys.exithelp) show_help();
+ va_start(va, msg);
+ verror_msg(msg, 0, va);
+ va_end(va);
+
+ xexit();
+}
+
+// Exit with an error message after showing help text.
+void help_exit(char *msg, ...)
+{
+ va_list va;
+
+ if (CFG_TOYBOX_HELP) show_help(stderr);
va_start(va, msg);
verror_msg(msg, 0, va);