summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authornicm <nicm>2013-10-10 12:09:34 +0000
committernicm <nicm>2013-10-10 12:09:34 +0000
commit6c093010e0c181433d263be54b65def01a8a3513 (patch)
treeccd0159ca04f137108abee2c5cb5b53f37f75516 /cmd-new-session.c
parentd2160e3f838bc2f5c08dffc0f05bc27502668ed7 (diff)
Remove CMD_SENDENVIRON.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 653db876..7c6ede62 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -30,29 +30,20 @@
* Create a new session and attach to the current terminal unless -d is given.
*/
-enum cmd_retval cmd_new_session_check(struct args *);
enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_new_session_entry = {
"new-session", "new",
- "AdDF:n:Ps:t:x:y:", 0, 1,
- "[-AdDP] [-F format] [-n window-name] [-s session-name] "
- CMD_TARGET_SESSION_USAGE " [-x width] [-y height] [command]",
- CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON,
+ "Ac:dDF:n:Ps:t:x:y:", 0, 1,
+ "[-AdDP] [-c start-directory] [-F format] [-n window-name] "
+ "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] [-y height] "
+ "[command]",
+ CMD_STARTSERVER|CMD_CANTNEST,
NULL,
- cmd_new_session_check,
cmd_new_session_exec
};
enum cmd_retval
-cmd_new_session_check(struct args *args)
-{
- if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n')))
- return (CMD_RETURN_ERROR);
- return (CMD_RETURN_NORMAL);
-}
-
-enum cmd_retval
cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
@@ -62,14 +53,19 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
struct environ env;
struct termios tio, *tiop;
struct passwd *pw;
- const char *newname, *target, *update, *cwd, *errstr;
- const char *template;
+ const char *newname, *target, *update, *base, *cwd;
+ const char *errstr, *template;
char *cmd, *cause, *cp;
int detached, idx;
u_int sx, sy;
int already_attached;
struct format_tree *ft;
+ 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);
+ }
+
newname = args_get(args, 's');
if (newname != NULL) {
if (!session_check_name(newname)) {
@@ -131,14 +127,19 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
/* Get the new session working directory. */
if (c != NULL && c->cwd != NULL)
- cwd = c->cwd;
+ base = c->cwd;
else {
pw = getpwuid(getuid());
if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
- cwd = pw->pw_dir;
+ base = pw->pw_dir;
else
- cwd = "/";
+ base = "/";
}
+ if (args_has(args, 'c'))
+ cwd = args_get(args, 'c');
+ else
+ cwd = options_get_string(&global_s_options, "default-path");
+ cwd = cmd_default_path(base, base, cwd);
/* Find new session size. */
if (c != NULL) {