summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/options-cmd.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-08-04 18:45:57 +0000
committernicm <nicm@openbsd.org>2009-08-04 18:45:57 +0000
commit4f5d8167ddc4ac09f683485a3a43faffe093096b (patch)
tree2cab300fb57a2b37582556ddad4efe9a0b603bcc /usr.bin/tmux/options-cmd.c
parentzap the rather useless machdep.apmwarn entries (see apm(4)); (diff)
downloadwireguard-openbsd-4f5d8167ddc4ac09f683485a3a43faffe093096b.tar.xz
wireguard-openbsd-4f5d8167ddc4ac09f683485a3a43faffe093096b.zip
Add a -a flag to set-option and set-window-option to append to an existing
string value, useful for terminal-overrides.
Diffstat (limited to 'usr.bin/tmux/options-cmd.c')
-rw-r--r--usr.bin/tmux/options-cmd.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/tmux/options-cmd.c b/usr.bin/tmux/options-cmd.c
index 4bc727316ab..747f8219756 100644
--- a/usr.bin/tmux/options-cmd.c
+++ b/usr.bin/tmux/options-cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options-cmd.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */
+/* $OpenBSD: options-cmd.c,v 1.2 2009/08/04 18:45:57 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -25,15 +25,26 @@
void
set_option_string(struct cmd_ctx *ctx, struct options *oo,
- const struct set_option_entry *entry, char *value)
+ const struct set_option_entry *entry, char *value, int append)
{
+ char *oldvalue, *newvalue;
+
if (value == NULL) {
ctx->error(ctx, "empty value");
return;
}
- options_set_string(oo, entry->name, "%s", value);
- ctx->info(ctx, "set option: %s -> %s", entry->name, value);
+ if (append) {
+ oldvalue = options_get_string(oo, entry->name);
+ xasprintf(&newvalue, "%s%s", oldvalue, value);
+ } else
+ newvalue = value;
+
+ options_set_string(oo, entry->name, "%s", newvalue);
+ ctx->info(ctx, "set option: %s -> %s", entry->name, newvalue);
+
+ if (newvalue != value)
+ xfree(newvalue);
}
void