mirror of
https://github.com/tmate-io/tmate.git
synced 2025-01-27 00:09:14 +01:00
Extend the -q flag to set-option to suppress errors about unknown
options - this will allow options to be removed more easily.
This commit is contained in:
parent
ebc5cb447f
commit
877bdb46ed
@ -117,9 +117,12 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (oe == NULL) {
|
if (oe == NULL) {
|
||||||
|
if (!args_has(args, 'q')) {
|
||||||
cmdq_error(cmdq, "unknown option: %s", optstr);
|
cmdq_error(cmdq, "unknown option: %s", optstr);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Work out the tree from the table. */
|
/* Work out the tree from the table. */
|
||||||
if (table == server_options_table)
|
if (table == server_options_table)
|
||||||
@ -163,8 +166,10 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
||||||
if (!args_has(args, 'q'))
|
if (!args_has(args, 'q')) {
|
||||||
cmdq_print(cmdq, "already set: %s", optstr);
|
cmdq_error(cmdq, "already set: %s", optstr);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
|
if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
|
||||||
@ -229,9 +234,12 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
|
|||||||
|
|
||||||
if (args_has(args, 'u')) {
|
if (args_has(args, 'u')) {
|
||||||
if (options_find1(oo, optstr) == NULL) {
|
if (options_find1(oo, optstr) == NULL) {
|
||||||
|
if (!args_has(args, 'q')) {
|
||||||
cmdq_error(cmdq, "unknown option: %s", optstr);
|
cmdq_error(cmdq, "unknown option: %s", optstr);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
if (valstr != NULL) {
|
if (valstr != NULL) {
|
||||||
cmdq_error(cmdq, "value passed to unset option: %s",
|
cmdq_error(cmdq, "value passed to unset option: %s",
|
||||||
optstr);
|
optstr);
|
||||||
@ -244,8 +252,10 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
||||||
if (!args_has(args, 'q'))
|
if (!args_has(args, 'q')) {
|
||||||
cmdq_print(cmdq, "already set: %s", optstr);
|
cmdq_error(cmdq, "already set: %s", optstr);
|
||||||
|
return CMD_RETURN_ERROR;
|
||||||
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
options_set_string(oo, optstr, "%s", valstr);
|
options_set_string(oo, optstr, "%s", valstr);
|
||||||
|
Loading…
Reference in New Issue
Block a user