diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-10-20 22:57:47 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-10-20 22:57:47 +0000 |
commit | dac6b8c98abd820b863e9c919be018cae1bffcda (patch) | |
tree | 2a4232914650768218d0b954077c75e279217ff9 /usr.bin | |
parent | 5c69c4be0b6b20e689fc8c59cbd976ffe09b6adb (diff) |
Move tiny has-session function into cmd-new-session.c.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-has-session.c | 46 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 16 |
3 files changed, 16 insertions, 49 deletions
diff --git a/usr.bin/tmux/Makefile b/usr.bin/tmux/Makefile index 1d31f72927f..bf860e1d9fa 100644 --- a/usr.bin/tmux/Makefile +++ b/usr.bin/tmux/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.72 2014/10/20 22:44:30 nicm Exp $ +# $OpenBSD: Makefile,v 1.73 2014/10/20 22:57:46 nicm Exp $ PROG= tmux SRCS= arguments.c \ @@ -22,7 +22,6 @@ SRCS= arguments.c \ cmd-display-message.c \ cmd-display-panes.c \ cmd-find-window.c \ - cmd-has-session.c \ cmd-if-shell.c \ cmd-join-pane.c \ cmd-kill-pane.c \ diff --git a/usr.bin/tmux/cmd-has-session.c b/usr.bin/tmux/cmd-has-session.c deleted file mode 100644 index fbd6e95a150..00000000000 --- a/usr.bin/tmux/cmd-has-session.c +++ /dev/null @@ -1,46 +0,0 @@ -/* $OpenBSD: cmd-has-session.c,v 1.10 2014/10/20 22:29:25 nicm Exp $ */ - -/* - * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> - -#include "tmux.h" - -/* - * Cause client to report an error and exit with 1 if session doesn't exist. - */ - -enum cmd_retval cmd_has_session_exec(struct cmd *, struct cmd_q *); - -const struct cmd_entry cmd_has_session_entry = { - "has-session", "has", - "t:", 0, 0, - CMD_TARGET_SESSION_USAGE, - 0, - cmd_has_session_exec -}; - -enum cmd_retval -cmd_has_session_exec(struct cmd *self, struct cmd_q *cmdq) -{ - struct args *args = self->args; - - if (cmd_find_session(cmdq, args_get(args, 't'), 0) == NULL) - return (CMD_RETURN_ERROR); - - return (CMD_RETURN_NORMAL); -} diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index 092b5a784ba..b4ec363bc9f 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.61 2014/10/20 22:29:25 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.62 2014/10/20 22:57:46 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -43,6 +43,14 @@ const struct cmd_entry cmd_new_session_entry = { cmd_new_session_exec }; +const struct cmd_entry cmd_has_session_entry = { + "has-session", "has", + "t:", 0, 0, + CMD_TARGET_SESSION_USAGE, + 0, + cmd_new_session_exec +}; + enum cmd_retval cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) { @@ -61,6 +69,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) struct format_tree *ft; struct environ_entry *envent; + if (self->entry == &cmd_has_session_entry) { + if (cmd_find_session(cmdq, args_get(args, 't'), 0) == NULL) + return (CMD_RETURN_ERROR); + return (CMD_RETURN_NORMAL); + } + if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) { cmdq_error(cmdq, "command or window name given with target"); return (CMD_RETURN_ERROR); |