aboutsummaryrefslogtreecommitdiff
path: root/cmd-set-option.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-set-option.c')
-rw-r--r--cmd-set-option.c68
1 files changed, 36 insertions, 32 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index 5ae4e5c3..01d691d5 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -69,7 +69,6 @@ const struct cmd_entry cmd_set_option_entry = {
"agoqst:uw", 1, 2,
"[-agosquw] [-t target-session|target-window] option [value]",
0,
- NULL,
cmd_set_option_exec
};
@@ -78,7 +77,6 @@ const struct cmd_entry cmd_set_window_option_entry = {
"agoqt:u", 1, 2,
"[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
0,
- NULL,
cmd_set_option_exec
};
@@ -117,8 +115,11 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
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. */
@@ -163,8 +164,10 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
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)
@@ -196,7 +199,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
/* Set user option. */
enum cmd_retval
-cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
+cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr,
const char *valstr)
{
struct args *args = self->args;
@@ -229,8 +232,11 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
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",
@@ -244,15 +250,13 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
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);
- if (!args_has(args, 'q')) {
- cmdq_info(cmdq, "set option: %s -> %s", optstr,
- valstr);
- }
}
return (CMD_RETURN_NORMAL);
}
@@ -261,7 +265,8 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
/* Unset an option. */
int
cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq,
- const struct options_table_entry *oe, struct options *oo, const char *value)
+ const struct options_table_entry *oe, struct options *oo,
+ const char *value)
{
struct args *args = self->args;
@@ -275,19 +280,16 @@ cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq,
}
options_remove(oo, oe->name);
- if (!args_has(args, 'q'))
- cmdq_info(cmdq, "unset option: %s", oe->name);
return (0);
}
/* Set an option. */
int
cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq,
- const struct options_table_entry *oe, struct options *oo, const char *value)
+ const struct options_table_entry *oe, struct options *oo,
+ const char *value)
{
- struct args *args = self->args;
struct options_entry *o;
- const char *s;
if (oe->type != OPTIONS_TABLE_FLAG && value == NULL) {
cmdq_error(cmdq, "empty value");
@@ -327,17 +329,14 @@ cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq,
}
if (o == NULL)
return (-1);
-
- s = options_table_print_entry(oe, o, 0);
- if (!args_has(args, 'q'))
- cmdq_info(cmdq, "set option: %s -> %s", oe->name, s);
return (0);
}
/* Set a string option. */
struct options_entry *
cmd_set_option_string(struct cmd *self, unused struct cmd_q *cmdq,
- const struct options_table_entry *oe, struct options *oo, const char *value)
+ const struct options_table_entry *oe, struct options *oo,
+ const char *value)
{
struct args *args = self->args;
struct options_entry *o;
@@ -358,7 +357,8 @@ cmd_set_option_string(struct cmd *self, unused struct cmd_q *cmdq,
/* Set a number option. */
struct options_entry *
cmd_set_option_number(unused struct cmd *self, struct cmd_q *cmdq,
- const struct options_table_entry *oe, struct options *oo, const char *value)
+ const struct options_table_entry *oe, struct options *oo,
+ const char *value)
{
long long ll;
const char *errstr;
@@ -375,7 +375,8 @@ cmd_set_option_number(unused struct cmd *self, struct cmd_q *cmdq,
/* Set a key option. */
struct options_entry *
cmd_set_option_key(unused struct cmd *self, struct cmd_q *cmdq,
- const struct options_table_entry *oe, struct options *oo, const char *value)
+ const struct options_table_entry *oe, struct options *oo,
+ const char *value)
{
int key;
@@ -390,7 +391,8 @@ cmd_set_option_key(unused struct cmd *self, struct cmd_q *cmdq,
/* Set a colour option. */
struct options_entry *
cmd_set_option_colour(unused struct cmd *self, struct cmd_q *cmdq,
- const struct options_table_entry *oe, struct options *oo, const char *value)
+ const struct options_table_entry *oe, struct options *oo,
+ const char *value)
{
int colour;
@@ -405,7 +407,8 @@ cmd_set_option_colour(unused struct cmd *self, struct cmd_q *cmdq,
/* Set an attributes option. */
struct options_entry *
cmd_set_option_attributes(unused struct cmd *self, struct cmd_q *cmdq,
- const struct options_table_entry *oe, struct options *oo, const char *value)
+ const struct options_table_entry *oe, struct options *oo,
+ const char *value)
{
int attr;
@@ -420,7 +423,8 @@ cmd_set_option_attributes(unused struct cmd *self, struct cmd_q *cmdq,
/* Set a flag option. */
struct options_entry *
cmd_set_option_flag(unused struct cmd *self, struct cmd_q *cmdq,
- const struct options_table_entry *oe, struct options *oo, const char *value)
+ const struct options_table_entry *oe, struct options *oo,
+ const char *value)
{
int flag;