OSDN Git Service

help_exit() tweak.
authorRob Landley <rob@landley.net>
Tue, 29 Sep 2015 10:32:57 +0000 (05:32 -0500)
committerRob Landley <rob@landley.net>
Tue, 29 Sep 2015 10:32:57 +0000 (05:32 -0500)
lib/lib.c
toys/other/sysctl.c

index 9e0a3a5..d9bea89 100644 (file)
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -56,9 +56,11 @@ void help_exit(char *msg, ...)
 
   if (CFG_TOYBOX_HELP) show_help(stderr);
 
-  va_start(va, msg);
-  verror_msg(msg, 0, va);
-  va_end(va);
+  if (msg) {
+    va_start(va, msg);
+    verror_msg(msg, 0, va);
+    va_end(va);
+  }
 
   xexit();
 }
index d4ed1b0..a123110 100644 (file)
@@ -19,7 +19,7 @@ config SYSCTL
     -e Don't warn about unknown keys
     -N Don't print key values
     -n Don't print key names
-    -p [FILE]  Read values from FILE (default /etc/sysctl.conf)
+    -p Read values from FILE (default /etc/sysctl.conf)
     -q Don't show value after write
     -w Only write values (object to reading)
 */
@@ -148,5 +148,8 @@ void sysctl_main()
     fclose(fp);
 
   // Loop through arguments, displaying or assigning as appropriate
-  } else for (args = toys.optargs; *args; args++) process_key(*args, 0);
+  } else {
+    if (!*toys.optargs) help_exit(0);
+    for (args = toys.optargs; *args; args++) process_key(*args, 0);
+  }
 }