diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-03-08 13:36:13 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-03-08 13:36:13 +0000 |
commit | c94e1662b904613e340920345437019f5f557ffd (patch) | |
tree | 78fcb46fbfe15a4144955bdc4e54b0fbfc8478bd /usr.bin/tmux/cmd-new-session.c | |
parent | 4f7325f29e5f70da51894bfd1796abbc35a24f9c (diff) |
Add a helper function for the most common format_create/defaults/expand
pattern.
Diffstat (limited to 'usr.bin/tmux/cmd-new-session.c')
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index 340b941714b..337d2e80173 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.101 2017/02/09 15:04:53 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.102 2017/03/08 13:36:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -78,7 +78,6 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) char **argv, *cause, *cp; int detached, already_attached, idx, argc; u_int sx, sy; - struct format_tree *ft; struct environ_entry *envent; struct cmd_find_state fs; @@ -155,10 +154,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) /* Get the new session working directory. */ if (args_has(args, 'c')) { - ft = format_create(item, FORMAT_NONE, 0); - format_defaults(ft, c, NULL, NULL, NULL); - to_free = cwd = format_expand(ft, args_get(args, 'c')); - format_free(ft); + cwd = args_get(args, 'c'); + to_free = cwd = format_single(item, cwd, c, NULL, NULL, NULL); } else if (c != NULL && c->session == NULL && c->cwd != NULL) cwd = c->cwd; else @@ -322,15 +319,9 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) if (args_has(args, 'P')) { if ((template = args_get(args, 'F')) == NULL) template = NEW_SESSION_TEMPLATE; - - ft = format_create(item, FORMAT_NONE, 0); - format_defaults(ft, c, s, NULL, NULL); - - cp = format_expand(ft, template); + cp = format_single(item, template, c, s, NULL, NULL); cmdq_print(item, "%s", cp); free(cp); - - format_free(ft); } if (!detached) |