diff options
author | Thomas Adam <thomas@xteddy.org> | 2017-02-14 20:01:12 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2017-02-14 20:01:12 +0000 |
commit | ba3c1534e08b495fc308ed0085148587e8ead3d0 (patch) | |
tree | a3161a2413826aeecaeca8b93b8abe7428163c6b /cmd-source-file.c | |
parent | 02e04477de73d01bb3ef12cb43a03cfc4c2e546c (diff) | |
parent | e340df2034c04591e3bbdcbcc22af1301cf74b09 (diff) | |
download | rtmux-ba3c1534e08b495fc308ed0085148587e8ead3d0.tar.gz rtmux-ba3c1534e08b495fc308ed0085148587e8ead3d0.tar.bz2 rtmux-ba3c1534e08b495fc308ed0085148587e8ead3d0.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-source-file.c')
-rw-r--r-- | cmd-source-file.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/cmd-source-file.c b/cmd-source-file.c index dce72c40..a367c7c2 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -22,6 +22,7 @@ #include <glob.h> #include <stdlib.h> #include <string.h> +#include <vis.h> #include "tmux.h" @@ -48,22 +49,35 @@ static enum cmd_retval cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; + int quiet = args_has(args, 'q'); struct client *c = item->client; - int quiet; struct cmdq_item *new_item; enum cmd_retval retval; + char *pattern, *tmp; + const char *path = args->argv[0]; glob_t g; u_int i; - quiet = args_has(args, 'q'); - if (glob(args->argv[0], 0, NULL, &g) != 0) { - if (quiet && errno == ENOENT) - return (CMD_RETURN_NORMAL); - cmdq_error(item, "%s: %s", args->argv[0], strerror(errno)); - return (CMD_RETURN_ERROR); + if (*path == '/') + pattern = xstrdup(path); + else { + utf8_stravis(&tmp, server_client_get_cwd(c), VIS_GLOB); + xasprintf(&pattern, "%s/%s", tmp, path); + free(tmp); } + log_debug("%s: %s", __func__, pattern); retval = CMD_RETURN_NORMAL; + if (glob(pattern, 0, NULL, &g) != 0) { + if (!quiet || errno != ENOENT) { + cmdq_error(item, "%s: %s", path, strerror(errno)); + retval = CMD_RETURN_ERROR; + } + free(pattern); + return (retval); + } + free(pattern); + for (i = 0; i < (u_int)g.gl_pathc; i++) { if (load_cfg(g.gl_pathv[i], c, item, quiet) != 0) retval = CMD_RETURN_ERROR; |