]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[cmdline] Fix "isset" command
authorMichael Brown <mcb30@ipxe.org>
Fri, 1 Apr 2011 19:07:17 +0000 (20:07 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 1 Apr 2011 19:09:51 +0000 (20:09 +0100)
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>
src/core/exec.c

index 8da288271128c602872036886910c837a6fb7725..008083bc3c1f04767a19b74f0b2afa6e306607de 100644 (file)
@@ -476,14 +476,20 @@ 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 iff any arguments exist */
-       return ( ( optind == argc ) ? -ENOENT : 0 );
+       /* Return success if any argument is non-empty */
+       for ( i = optind ; i < argc ; i++ ) {
+               if ( argv[i][0] != '\0' )
+                       return 0;
+       }
+
+       return -ENOENT;
 }
 
 /** "isset" command */