aboutsummaryrefslogtreecommitdiff
path: root/cmd-set-option.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2021-08-20 22:01:46 +0100
committerThomas Adam <thomas@xteddy.org>2021-08-20 22:01:46 +0100
commitb0da0cee4d54aa64db0f49eee509a76fd89d6f68 (patch)
tree1e54ddb0b113708c46e80d342d10be74cdf7b176 /cmd-set-option.c
parent944fde7c57c4f3caebb04cfc3943a81ee9729de8 (diff)
parentd589be6c65c7295880bb84cd875baab2f77d5067 (diff)
downloadrtmux-b0da0cee4d54aa64db0f49eee509a76fd89d6f68.tar.gz
rtmux-b0da0cee4d54aa64db0f49eee509a76fd89d6f68.tar.bz2
rtmux-b0da0cee4d54aa64db0f49eee509a76fd89d6f68.zip
Merge branch 'obsd-master' into master
Diffstat (limited to 'cmd-set-option.c')
-rw-r--r--cmd-set-option.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index 70e3c54d..48e04eed 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -77,14 +77,16 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
struct window_pane *loop;
struct options *oo;
struct options_entry *parent, *o, *po;
- char *name, *argument, *value = NULL, *cause;
+ char *name, *argument, *expanded = NULL;
+ char *cause;
+ const char *value;
int window, idx, already, error, ambiguous;
int scope;
window = (cmd_get_entry(self) == &cmd_set_window_option_entry);
/* Expand argument. */
- argument = format_single_from_target(item, args->argv[0]);
+ argument = format_single_from_target(item, args_string(args, 0));
/* If set-hook -R, fire the hook straight away. */
if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'R')) {
@@ -104,12 +106,14 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "invalid option: %s", argument);
goto fail;
}
- if (args->argc < 2)
+ if (args_count(args) < 2)
value = NULL;
- else if (args_has(args, 'F'))
- value = format_single_from_target(item, args->argv[1]);
else
- value = xstrdup(args->argv[1]);
+ value = args_string(args, 1);
+ if (value != NULL && args_has(args, 'F')) {
+ expanded = format_single_from_target(item, value);
+ value = expanded;
+ }
/* Get the scope and table for the option .*/
scope = options_scope_from_name(args, window, name, target, &oo,
@@ -211,13 +215,13 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
out:
free(argument);
- free(value);
+ free(expanded);
free(name);
return (CMD_RETURN_NORMAL);
fail:
free(argument);
- free(value);
+ free(expanded);
free(name);
return (CMD_RETURN_ERROR);
}