summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2013-10-01 23:48:03 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2013-10-01 23:48:03 +0100
commit9389cfbec9d7f4a7b5f9d4a580428949db4f6e67 (patch)
treee100b22e38d503ff465b3a5ec669f0493d126fda /cmd-new-session.c
parentd62121e7bbab6c84faa7beb2117cb9e444866db3 (diff)
Support -c for new-session, based on code from J Raynor.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index b1e1aa45..1c743a8e 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -34,9 +34,10 @@ 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]",
+ "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|CMD_SENDENVIRON,
NULL,
cmd_new_session_exec
@@ -52,8 +53,8 @@ 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;
@@ -126,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) {