diff options
author | Rob Landley <rob@landley.net> | 2015-09-11 16:35:14 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-09-11 16:35:14 -0500 |
commit | e5354ca12a232b3f97726214254a868771cb70d1 (patch) | |
tree | ba373c24ede64b8a18f11a02cf834ce99aa586bf /lib/lib.c | |
parent | d067571abb2b7934f3350c90ca891beb987c68fd (diff) | |
download | toybox-e5354ca12a232b3f97726214254a868771cb70d1.tar.gz |
Replace toys.exithelp with help_exit() in lib.
Diffstat (limited to 'lib/lib.c')
-rw-r--r-- | lib/lib.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -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); |