aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-10-10 18:16:08 -0500
committerRob Landley <rob@landley.net>2017-10-10 18:16:08 -0500
commit46d2cda500242caae2ccf7cee71200d4bfe7c7a5 (patch)
tree47dbe9ebf18a79b46ffc0c91c71d4b66622dce8b
parent3eb69d412e79d7d7db197c9a8592ba944a0af77e (diff)
downloadtoybox-46d2cda500242caae2ccf7cee71200d4bfe7c7a5.tar.gz
Tweak help_exit() to show "See %s --help" message on the same line.
-rw-r--r--lib/lib.c12
-rw-r--r--toys/other/sysctl.c2
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/lib.c b/lib/lib.c
index fae71566..80570ed1 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -12,7 +12,9 @@ void verror_msg(char *msg, int err, va_list va)
fprintf(stderr, "%s: ", toys.which->name);
if (msg) vfprintf(stderr, msg, va);
else s+=2;
- if (err) fprintf(stderr, s, strerror(err));
+ if (err>0) fprintf(stderr, s, strerror(err));
+ if (err<0 && CFG_TOYBOX_HELP)
+ fprintf(stderr, " (See \"%s --help\")", toys.which->name);
if (msg || err) putc('\n', stderr);
if (!toys.exitval) toys.exitval++;
}
@@ -66,12 +68,10 @@ void help_exit(char *msg, ...)
{
va_list va;
- if (CFG_TOYBOX_HELP)
- fprintf(stderr, "See %s --help\n", toys.which->name);
-
- if (msg) {
+ if (!msg) show_help(stdout);
+ else {
va_start(va, msg);
- verror_msg(msg, 0, va);
+ verror_msg(msg, -1, va);
va_end(va);
}
diff --git a/toys/other/sysctl.c b/toys/other/sysctl.c
index ad643c92..37735942 100644
--- a/toys/other/sysctl.c
+++ b/toys/other/sysctl.c
@@ -149,7 +149,7 @@ void sysctl_main()
// Loop through arguments, displaying or assigning as appropriate
} else {
- if (!*toys.optargs) help_exit(0);
+ if (!*toys.optargs) help_exit("Needs 1 arg");
for (args = toys.optargs; *args; args++) process_key(*args, 0);
}
}