summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-source-file.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2017-01-09 19:27:00 +0000
committernicm <nicm@openbsd.org>2017-01-09 19:27:00 +0000
commit079748ec84aa62c63345c85dee0a3cfb327780d3 (patch)
tree78729d215cbf54b2afc820b5feac1658bf40df85 /usr.bin/tmux/cmd-source-file.c
parentUse a mutex to serialize accesses to buffer slots. (diff)
downloadwireguard-openbsd-079748ec84aa62c63345c85dee0a3cfb327780d3.tar.xz
wireguard-openbsd-079748ec84aa62c63345c85dee0a3cfb327780d3.zip
Run the source-file pattern through glob(3).
Diffstat (limited to 'usr.bin/tmux/cmd-source-file.c')
-rw-r--r--usr.bin/tmux/cmd-source-file.c30
1 files changed, 19 insertions, 11 deletions
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 <me@tiagocunha.org>
@@ -18,7 +18,10 @@
#include <sys/types.h>
+#include <errno.h>
+#include <glob.h>
#include <stdlib.h>
+#include <string.h>
#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