-/* $OpenBSD: cmd-set-option.c,v 1.66 2014/02/17 18:12:47 nicm Exp $ */
+/* $OpenBSD: cmd-set-option.c,v 1.67 2014/04/17 07:51:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
return (CMD_RETURN_ERROR);
}
if (oe == NULL) {
- cmdq_error(cmdq, "unknown option: %s", optstr);
- return (CMD_RETURN_ERROR);
+ if (!args_has(args, 'q')) {
+ cmdq_error(cmdq, "unknown option: %s", optstr);
+ return (CMD_RETURN_ERROR);
+ }
+ return (CMD_RETURN_NORMAL);
}
/* Work out the tree from the table. */
return (CMD_RETURN_ERROR);
} else {
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
- if (!args_has(args, 'q'))
- cmdq_print(cmdq, "already set: %s", optstr);
+ if (!args_has(args, 'q')) {
+ cmdq_error(cmdq, "already set: %s", optstr);
+ return (CMD_RETURN_ERROR);
+ }
return (CMD_RETURN_NORMAL);
}
if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
if (args_has(args, 'u')) {
if (options_find1(oo, optstr) == NULL) {
- cmdq_error(cmdq, "unknown option: %s", optstr);
- return (CMD_RETURN_ERROR);
+ if (!args_has(args, 'q')) {
+ cmdq_error(cmdq, "unknown option: %s", optstr);
+ return (CMD_RETURN_ERROR);
+ }
+ return (CMD_RETURN_NORMAL);
}
if (valstr != NULL) {
cmdq_error(cmdq, "value passed to unset option: %s",
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
- if (!args_has(args, 'q'))
- cmdq_print(cmdq, "already set: %s", optstr);
+ if (!args_has(args, 'q')) {
+ cmdq_error(cmdq, "already set: %s", optstr);
+ return CMD_RETURN_ERROR;
+ }
return (CMD_RETURN_NORMAL);
}
options_set_string(oo, optstr, "%s", valstr);