From 4e005dd359990638f38d06ebf4dabd919cbd63b9 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 9 Jan 2017 19:27:01 +0000 Subject: Run the source-file pattern through glob(3). --- usr.bin/tmux/cfg.c | 12 ++++++------ usr.bin/tmux/cmd-source-file.c | 30 +++++++++++++++++++----------- usr.bin/tmux/tmux.1 | 9 ++++++--- usr.bin/tmux/tmux.h | 4 ++-- 4 files changed, 33 insertions(+), 22 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/tmux/cfg.c b/usr.bin/tmux/cfg.c index b5ad5dbbd59..288929e4999 100644 --- a/usr.bin/tmux/cfg.c +++ b/usr.bin/tmux/cfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfg.c,v 1.50 2016/10/16 19:04:05 nicm Exp $ */ +/* $OpenBSD: cfg.c,v 1.51 2017/01/09 19:27:00 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -28,11 +28,11 @@ #include "tmux.h" -char *cfg_file; -int cfg_finished; -static char **cfg_causes; -static u_int cfg_ncauses; -struct client *cfg_client; +char *cfg_file; +int cfg_finished; +static char **cfg_causes; +static u_int cfg_ncauses; +struct client *cfg_client; static enum cmd_retval cfg_done(__unused struct cmdq_item *item, __unused void *data) diff --git a/usr.bin/tmux/cmd-source-file.c b/usr.bin/tmux/cmd-source-file.c index 33213880275..bfac10a6ddc 100644 --- a/usr.bin/tmux/cmd-source-file.c +++ b/usr.bin/tmux/cmd-source-file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-source-file.c,v 1.30 2016/10/16 19:04:05 nicm Exp $ */ +/* $OpenBSD: cmd-source-file.c,v 1.31 2017/01/09 19:27:00 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha @@ -18,7 +18,10 @@ #include +#include +#include #include +#include #include "tmux.h" @@ -48,23 +51,28 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) struct client *c = item->client; int quiet; struct cmdq_item *new_item; + enum cmd_retval retval; + glob_t g; + int i; - quiet = args_has(args, 'q'); - switch (load_cfg(args->argv[0], c, item, quiet)) { - case -1: - if (cfg_finished) - cfg_print_causes(item); + if (glob(args->argv[0], 0, NULL, &g) != 0) { + cmdq_error(item, "%s: %s", args->argv[0], strerror(errno)); return (CMD_RETURN_ERROR); - case 0: - if (cfg_finished) - cfg_print_causes(item); - return (CMD_RETURN_NORMAL); + } + quiet = args_has(args, 'q'); + + retval = CMD_RETURN_NORMAL; + for (i = 0; i < g.gl_pathc; i++) { + if (load_cfg(g.gl_pathv[i], c, item, quiet) != 0) + retval = CMD_RETURN_ERROR; } if (cfg_finished) { new_item = cmdq_get_callback(cmd_source_file_done, NULL); cmdq_insert_after(item, new_item); } - return (CMD_RETURN_NORMAL); + + globfree(&g); + return (retval); } static enum cmd_retval diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 173a2700940..4b7b4b6d468 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.518 2017/01/07 15:40:23 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.519 2017/01/09 19:27:00 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 7 2017 $ +.Dd $Mdocdate: January 9 2017 $ .Dt TMUX 1 .Os .Sh NAME @@ -921,7 +921,10 @@ show debugging information about jobs and terminals. .Xc .D1 (alias: Ic source ) Execute commands from -.Ar path . +.Ar path +(which may be a +.Xr glob 3 +pattern). If .Fl q is given, no error will be returned if diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 722520a8743..816c049325a 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.685 2017/01/07 15:28:13 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.686 2017/01/09 19:27:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -76,7 +76,7 @@ struct tmuxproc; #define READ_CHANGE_HITS 3 -/* Attribute to make gcc check printf-like arguments. */ +/* Attribute to make GCC check printf-like arguments. */ #define printflike(a, b) __attribute__ ((format (printf, a, b))) /* Number of items in array. */ -- cgit v1.2.3