Browse Source

[cmdline] Fix "isset" command

Commit b5f5f73 ("[cmdline] Expand settings within each command-line
token individually") introduced a regression into the "isset" command:
it is now possible for command-line arguments to be empty strings, and
so "isset" cannot simply check for a non-empty argument list.

Restore previous behaviour by checking for the presence of any
non-empty arguments, rather than checking for a non-empty argument
list.

Reported-by: Nemtallah Daher <n.daher@csuohio.edu>
Tested-by: Nemtallah Daher <n.daher@csuohio.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
06f1878fb8
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      src/core/exec.c

+ 8
- 2
src/core/exec.c View File

476
  */
476
  */
477
 static int isset_exec ( int argc, char **argv ) {
477
 static int isset_exec ( int argc, char **argv ) {
478
 	struct isset_options opts;
478
 	struct isset_options opts;
479
+	int i;
479
 	int rc;
480
 	int rc;
480
 
481
 
481
 	/* Parse options */
482
 	/* Parse options */
482
 	if ( ( rc = parse_options ( argc, argv, &isset_cmd, &opts ) ) != 0 )
483
 	if ( ( rc = parse_options ( argc, argv, &isset_cmd, &opts ) ) != 0 )
483
 		return rc;
484
 		return rc;
484
 
485
 
485
-	/* Return success iff any arguments exist */
486
-	return ( ( optind == argc ) ? -ENOENT : 0 );
486
+	/* Return success if any argument is non-empty */
487
+	for ( i = optind ; i < argc ; i++ ) {
488
+		if ( argv[i][0] != '\0' )
489
+			return 0;
490
+	}
491
+
492
+	return -ENOENT;
487
 }
493
 }
488
 
494
 
489
 /** "isset" command */
495
 /** "isset" command */

Loading…
Cancel
Save