From: nicm Date: Thu, 2 Jun 2022 20:41:21 +0000 (+0000) Subject: When deleting or renaming a buffer and a buffer name is specified, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=40755b4beabc5ba6da5c59d65fbe271f9eaea499;p=openbsd When deleting or renaming a buffer and a buffer name is specified, complain if the buffer doesn't exist instead of silently deleting or renaming the most recent buffer. GitHub issue 3205. --- diff --git a/usr.bin/tmux/cmd-set-buffer.c b/usr.bin/tmux/cmd-set-buffer.c index f90774459d1..e6e10a871ae 100644 --- a/usr.bin/tmux/cmd-set-buffer.c +++ b/usr.bin/tmux/cmd-set-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-buffer.c,v 1.32 2021/08/21 10:22:39 nicm Exp $ */ +/* $OpenBSD: cmd-set-buffer.c,v 1.33 2022/06/02 20:41:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -69,8 +69,13 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item) pb = paste_get_name(bufname); if (cmd_get_entry(self) == &cmd_delete_buffer_entry) { - if (pb == NULL) + if (pb == NULL) { + if (bufname != NULL) { + cmdq_error(item, "unknown buffer: %s", bufname); + return (CMD_RETURN_ERROR); + } pb = paste_get_top(&bufname); + } if (pb == NULL) { cmdq_error(item, "no buffer"); return (CMD_RETURN_ERROR); @@ -80,8 +85,13 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item) } if (args_has(args, 'n')) { - if (pb == NULL) + if (pb == NULL) { + if (bufname != NULL) { + cmdq_error(item, "unknown buffer: %s", bufname); + return (CMD_RETURN_ERROR); + } pb = paste_get_top(&bufname); + } if (pb == NULL) { cmdq_error(item, "no buffer"); return (CMD_RETURN_ERROR);