diff options
author | Rob Landley <rob@landley.net> | 2017-03-20 12:41:22 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2017-03-20 12:41:22 -0500 |
commit | cb8e5ad6c5b9c79cce1a6baf10041f90cf491711 (patch) | |
tree | 7d22e62919b40e845380b32486e8a61991329715 | |
parent | 2ba9c414e02197075e7e90ca077dda19fae75cda (diff) | |
download | toybox-cb8e5ad6c5b9c79cce1a6baf10041f90cf491711.tar.gz |
Add TOYBOX_PEDANTIC_ARGS to check arguments when there are no arguments,
and make uptime use it.
-rw-r--r-- | Config.in | 6 | ||||
-rw-r--r-- | lib/toyflags.h | 6 | ||||
-rwxr-xr-x | scripts/make.sh | 1 | ||||
-rw-r--r-- | toys/other/uptime.c | 2 |
4 files changed, 14 insertions, 1 deletions
@@ -135,6 +135,12 @@ config TOYBOX_DEBUG Enable extra checks for debugging purposes. All of them catch things that can only go wrong at development time, not runtime. +config TOYBOX_PEDANTIC_ARGS + bool "Pedantic argument checking" + default n + help + Check arguments for commands that have no arguments. + config TOYBOX_UID_SYS int "First system UID" default 100 diff --git a/lib/toyflags.h b/lib/toyflags.h index e809901d..859cca2e 100644 --- a/lib/toyflags.h +++ b/lib/toyflags.h @@ -28,3 +28,9 @@ // Suppress default --help processing #define TOYFLAG_NOHELP (1<<9) + +#if CFG_TOYBOX_PEDANTIC_ARGS +#define NO_ARGS ">0" +#else +#define NO_ARGS 0 +#endif diff --git a/scripts/make.sh b/scripts/make.sh index 6b853840..57928471 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -182,6 +182,7 @@ make_flagsh() else $SED '/USE_.*([^)]*)$/s/$/ __VA_ARGS__/' generated/config.h fi + echo '#include "lib/toyflags.h"' cat generated/newtoys.h # Run result through preprocessor, glue together " " gaps leftover from USE diff --git a/toys/other/uptime.c b/toys/other/uptime.c index 91887dfb..1acb39ef 100644 --- a/toys/other/uptime.c +++ b/toys/other/uptime.c @@ -5,7 +5,7 @@ * Copyright 2013 Jeroen van Rijn <jvrnix@gmail.com> -USE_UPTIME(NEWTOY(uptime, NULL, TOYFLAG_USR|TOYFLAG_BIN)) +USE_UPTIME(NEWTOY(uptime, NO_ARGS, TOYFLAG_USR|TOYFLAG_BIN)) config UPTIME bool "uptime" |