mirror of https://github.com/ipxe/ipxe.git
[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>pull/5/head
parent
15c120041d
commit
7aee315f61
|
@ -464,8 +464,7 @@ static struct option_descriptor isset_opts[] = {};
|
||||||
|
|
||||||
/** "isset" command descriptor */
|
/** "isset" command descriptor */
|
||||||
static struct command_descriptor isset_cmd =
|
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
|
* "isset" command
|
||||||
|
@ -476,20 +475,14 @@ static struct command_descriptor isset_cmd =
|
||||||
*/
|
*/
|
||||||
static int isset_exec ( int argc, char **argv ) {
|
static int isset_exec ( int argc, char **argv ) {
|
||||||
struct isset_options opts;
|
struct isset_options opts;
|
||||||
int i;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Parse options */
|
/* Parse options */
|
||||||
if ( ( rc = parse_options ( argc, argv, &isset_cmd, &opts ) ) != 0 )
|
if ( ( rc = parse_options ( argc, argv, &isset_cmd, &opts ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Return success if any argument is non-empty */
|
/* Return success iff argument is non-empty */
|
||||||
for ( i = optind ; i < argc ; i++ ) {
|
return ( argv[optind][0] ? 0 : -ENOENT );
|
||||||
if ( argv[i][0] != '\0' )
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "isset" command */
|
/** "isset" command */
|
||||||
|
|
Loading…
Reference in New Issue