=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-set-option.c,v retrieving revision 1.138 retrieving revision 1.139 diff -u -r1.138 -r1.139 --- src/usr.bin/tmux/cmd-set-option.c 2020/12/15 08:31:50 1.138 +++ src/usr.bin/tmux/cmd-set-option.c 2021/08/20 19:50:17 1.139 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.138 2020/12/15 08:31:50 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.139 2021/08/20 19:50:17 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -77,14 +77,16 @@ 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 @@ 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 @@ 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); }