diff options
author | 2019-05-20 13:23:32 +0000 | |
---|---|---|
committer | 2019-05-20 13:23:32 +0000 | |
commit | 44c91ad457c818b96ffccb6d62fc1bb1748d16b9 (patch) | |
tree | c37248360c0ee7d67f33fca1b6194789059cb751 /usr.bin/tmux/cmd-source-file.c | |
parent | Replace the various identical error callbacks with a single one in cmd-queue.c. (diff) | |
download | wireguard-openbsd-44c91ad457c818b96ffccb6d62fc1bb1748d16b9.tar.xz wireguard-openbsd-44c91ad457c818b96ffccb6d62fc1bb1748d16b9.zip |
Fix ordering of source-file with multiple files and add flags to load_cfg.
Diffstat (limited to 'usr.bin/tmux/cmd-source-file.c')
-rw-r--r-- | usr.bin/tmux/cmd-source-file.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/tmux/cmd-source-file.c b/usr.bin/tmux/cmd-source-file.c index 6c55a446e07..eab89c3788d 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.36 2018/05/24 09:42:49 nicm Exp $ */ +/* $OpenBSD: cmd-source-file.c,v 1.37 2019/05/20 13:23:32 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org> @@ -49,15 +49,18 @@ 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'); + int flags = 0; struct client *c = item->client; - struct cmdq_item *new_item; + struct cmdq_item *new_item, *after; enum cmd_retval retval; char *pattern, *tmp; const char *path = args->argv[0]; glob_t g; u_int i; + if (args_has(args, 'q')) + flags |= CFG_QUIET; + if (*path == '/') pattern = xstrdup(path); else { @@ -69,7 +72,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) retval = CMD_RETURN_NORMAL; if (glob(pattern, 0, NULL, &g) != 0) { - if (!quiet || errno != ENOENT) { + if (errno != ENOENT || (~flags & CFG_QUIET)) { cmdq_error(item, "%s: %s", path, strerror(errno)); retval = CMD_RETURN_ERROR; } @@ -78,9 +81,12 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) } free(pattern); + after = item; for (i = 0; i < (u_int)g.gl_pathc; i++) { - if (load_cfg(g.gl_pathv[i], c, item, quiet) < 0) + if (load_cfg(g.gl_pathv[i], c, after, flags, &new_item) < 0) retval = CMD_RETURN_ERROR; + else if (new_item != NULL) + after = new_item; } if (cfg_finished) { new_item = cmdq_get_callback(cmd_source_file_done, NULL); |