diff options
author | Michael Brown | 2011-04-08 04:19:06 +0200 |
---|---|---|
committer | Michael Brown | 2011-04-08 04:19:06 +0200 |
commit | 7aee315f61aaf1be6d2fff26339f28a1137231a5 (patch) | |
tree | db118ec8afc3f93a352bd08b630e335b0cbe97aa /src/core/exec.c | |
parent | [hermon] Work around missing mport support in current BOFM implementations (diff) | |
download | ipxe-7aee315f61aaf1be6d2fff26339f28a1137231a5.tar.gz ipxe-7aee315f61aaf1be6d2fff26339f28a1137231a5.tar.xz ipxe-7aee315f61aaf1be6d2fff26339f28a1137231a5.zip |
[cmdline] Simplify "isset" command
There is no plausible scenario I can think of in which "isset" would
be used with more than one argument. Simplify the code by specifying
that exactly one argument is required.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/exec.c')
-rw-r--r-- | src/core/exec.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/core/exec.c b/src/core/exec.c index 008083bc..18d3477e 100644 --- a/src/core/exec.c +++ b/src/core/exec.c @@ -464,8 +464,7 @@ static struct option_descriptor isset_opts[] = {}; /** "isset" command descriptor */ static struct command_descriptor isset_cmd = - COMMAND_DESC ( struct isset_options, isset_opts, 0, MAX_ARGUMENTS, - "[...]" ); + COMMAND_DESC ( struct isset_options, isset_opts, 1, 1, "<value>" ); /** * "isset" command @@ -476,20 +475,14 @@ static struct command_descriptor isset_cmd = */ static int isset_exec ( int argc, char **argv ) { struct isset_options opts; - int i; int rc; /* Parse options */ if ( ( rc = parse_options ( argc, argv, &isset_cmd, &opts ) ) != 0 ) return rc; - /* Return success if any argument is non-empty */ - for ( i = optind ; i < argc ; i++ ) { - if ( argv[i][0] != '\0' ) - return 0; - } - - return -ENOENT; + /* Return success iff argument is non-empty */ + return ( argv[optind][0] ? 0 : -ENOENT ); } /** "isset" command */ |