diff options
author | 2016-05-12 16:05:33 +0000 | |
---|---|---|
committer | 2016-05-12 16:05:33 +0000 | |
commit | 59c70a5f496903cd63171d4b0571fc530f9ac47a (patch) | |
tree | b0ba2f331668a3447170fc84db239c9735e4a3fa /usr.bin/tmux/cmd-source-file.c | |
parent | Using a 3-word buffer in the openbsd.randomdata segment, XOR swizzle (diff) | |
download | wireguard-openbsd-59c70a5f496903cd63171d4b0571fc530f9ac47a.tar.xz wireguard-openbsd-59c70a5f496903cd63171d4b0571fc530f9ac47a.zip |
- Rework load_cfg() error handling a little.
- Add -q to source-file to suppress errors about nonexistent files.
Input and OK nicm@
Diffstat (limited to 'usr.bin/tmux/cmd-source-file.c')
-rw-r--r-- | usr.bin/tmux/cmd-source-file.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/usr.bin/tmux/cmd-source-file.c b/usr.bin/tmux/cmd-source-file.c index 31a1eaca606..1206af6d818 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.24 2016/04/29 14:05:24 nicm Exp $ */ +/* $OpenBSD: cmd-source-file.c,v 1.25 2016/05/12 16:05:33 tim Exp $ */ /* * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org> @@ -34,8 +34,8 @@ const struct cmd_entry cmd_source_file_entry = { .name = "source-file", .alias = "source", - .args = { "", 1, 1 }, - .usage = "path", + .args = { "q", 1, 1 }, + .usage = "[-q] path", .flags = 0, .exec = cmd_source_file_exec @@ -46,28 +46,26 @@ cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct cmd_q *cmdq1; - char *cause; + int quiet; cmdq1 = cmdq_new(cmdq->client); cmdq1->flags |= cmdq->flags & CMD_Q_NOHOOKS; cmdq1->emptyfn = cmd_source_file_done; cmdq1->data = cmdq; - switch (load_cfg(args->argv[0], cmdq1, &cause)) { + quiet = args_has(args, 'q'); + switch (load_cfg(args->argv[0], cmdq1, quiet)) { case -1: + cmdq_free(cmdq1); if (cfg_references == 0) { - cmdq_free(cmdq1); - cmdq_error(cmdq, "%s", cause); - free(cause); + cfg_print_causes(cmdq); return (CMD_RETURN_ERROR); } - cfg_add_cause("%s", cause); - free(cause); - /* FALLTHROUGH */ + return (CMD_RETURN_NORMAL); case 0: + cmdq_free(cmdq1); if (cfg_references == 0) cfg_print_causes(cmdq); - cmdq_free(cmdq1); return (CMD_RETURN_NORMAL); } |