* to the option if found, 0 with *OPT set to NULL if the name is
* valid and the option is not required, -1 with *OPT set to NULL if
* the option is required but not present, and assert if NAME is not
- * valid (which indicates a programming error). No error messages are
- * issued if a value is returned.
+ * valid (which indicates a programming error) unless cmd->skipChecks
+ * is set. No error messages are issued if a value is returned.
*/
static int
vshCommandOpt(const vshCmd *cmd, const char *name, vshCmdOpt **opt,
/* See if option is valid and/or required. */
*opt = NULL;
- while (valid) {
- assert(valid->name);
- if (STREQ(name, valid->name))
- break;
- valid++;
+
+ if (!cmd->skipChecks) {
+ while (valid && valid->name) {
+ if (STREQ(name, valid->name))
+ break;
+ valid++;
+ }
+
+ assert(valid && (!needData || valid->type != VSH_OT_BOOL));
+
+ if (valid->flags & VSH_OFLAG_REQ)
+ ret = -1;
}
- assert(!needData || valid->type != VSH_OT_BOOL);
- if (valid->flags & VSH_OFLAG_REQ)
- ret = -1;
/* See if option is present on command line. */
while (candidate) {
struct _vshCmd {
const vshCmdDef *def; /* command definition */
vshCmdOpt *opts; /* list of command arguments */
- vshCmd *next; /* next command */
+ vshCmd *next; /* next command */
+ bool skipChecks; /* skip validity checks when retrieving opts */
};
/*