mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
Move tiny has-session function into cmd-new-session.c.
This commit is contained in:
parent
40726d9e1c
commit
10d7b7975b
@ -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 \
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user