Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv21622

Modified Files:
        cmd-new-session.c cmd-new-window.c cmd-split-window.c 
        session.c tmux.1 tmux.c tmux.h 
Log Message:
Sync OpenBSD patchset 730:

Store the current working directory in the session, change the default-path
option to default to empty and make that mean that the stored session CWD is
used.


Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.261
retrieving revision 1.262
diff -u -d -r1.261 -r1.262
--- tmux.1      2 Jul 2010 02:45:52 -0000       1.261
+++ tmux.1      2 Jul 2010 02:49:19 -0000       1.262
@@ -1626,7 +1626,8 @@
 .It Ic default-path Ar path
 Set the default working directory for processes created from keys, or
 interactively from the prompt.
-The default is the current working directory when the server is started.
+The default is empty, which means to use the working directory of the shell
+from which the server was started if it is available or the user's home if not.
 .It Ic default-terminal Ar terminal
 Set the default terminal for new windows created in this session - the
 default value of the

Index: cmd-new-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-new-session.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- cmd-new-session.c   5 Apr 2010 05:11:43 -0000       1.77
+++ cmd-new-session.c   2 Jul 2010 02:49:19 -0000       1.78
@@ -18,8 +18,10 @@
 
 #include <sys/types.h>
 
+#include <pwd.h>
 #include <string.h>
 #include <termios.h>
+#include <unistd.h>
 
 #include "tmux.h"
 
@@ -125,8 +127,9 @@
        struct window_pane              *wp;
        struct environ                   env;
        struct termios                   tio, *tiop;
-       const char                      *update;
-       char                            *overrides, *cmd, *cwd, *cause;
+       struct passwd                   *pw;
+       const char                      *update, *cwd;
+       char                            *overrides, *cmd, *cause;
        int                              detached, idx;
        u_int                            sx, sy, i;
 
@@ -198,8 +201,13 @@
        /* Get the new session working directory. */
        if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
                cwd = ctx->cmdclient->cwd;
-       else
-               cwd = options_get_string(&global_s_options, "default-path");
+       else {
+               pw = getpwuid(getuid());
+               if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
+                       cwd = pw->pw_dir;
+               else
+                       cwd = "/";
+       }
 
        /* Find new session size. */
        if (detached) {

Index: tmux.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.c,v
retrieving revision 1.211
retrieving revision 1.212
diff -u -d -r1.211 -r1.212
--- tmux.c      2 Jul 2010 02:45:52 -0000       1.211
+++ tmux.c      2 Jul 2010 02:49:19 -0000       1.212
@@ -242,7 +242,7 @@
        struct env_data          envdata;
        struct msg_command_data  cmddata;
        char                    *s, *shellcmd, *path, *label, *home, *cause;
-       char                     cwd[MAXPATHLEN], **var;
+       char                   **var;
        void                    *buf;
        size_t                   len;
        int                      opt, flags, quiet = 0, cmdflags = 0;
@@ -342,6 +342,7 @@
        options_set_number(so, "bell-action", BELL_ANY);
        options_set_number(so, "buffer-limit", 9);
        options_set_string(so, "default-command", "%s", "");
+       options_set_string(so, "default-path", "%s", "");
        options_set_string(so, "default-shell", "%s", getshell());
        options_set_string(so, "default-terminal", "screen");
        options_set_number(so, "detach-on-destroy", 1);
@@ -438,15 +439,6 @@
                options_set_number(wo, "utf8", 0);
        }
 
-       if (getcwd(cwd, sizeof cwd) == NULL) {
-               pw = getpwuid(getuid());
-               if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
-                       strlcpy(cwd, pw->pw_dir, sizeof cwd);
-               else
-                       strlcpy(cwd, "/", sizeof cwd);
-       }
-       options_set_string(so, "default-path", "%s", cwd);
-
        if (cfg_file == NULL) {
                home = getenv("HOME");
                if (home == NULL || *home == '\0') {

Index: cmd-split-window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-split-window.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- cmd-split-window.c  8 Jan 2010 16:31:35 -0000       1.34
+++ cmd-split-window.c  2 Jul 2010 02:49:19 -0000       1.35
@@ -169,10 +169,13 @@
        cmd = data->cmd;
        if (cmd == NULL)
                cmd = options_get_string(&s->options, "default-command");
-       if (ctx->cmdclient == NULL || ctx->cmdclient->cwd == NULL)
-               cwd = options_get_string(&s->options, "default-path");
-       else
-               cwd = ctx->cmdclient->cwd;
+       cwd = options_get_string(&s->options, "default-path");
+       if (*cwd == '\0') {
+               if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
+                       cwd = ctx->cmdclient->cwd;
+               else
+                       cwd = s->cwd;
+       }
 
        type = LAYOUT_TOPBOTTOM;
        if (data->flag_horizontal)

Index: session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/session.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- session.c   22 Jun 2010 23:26:18 -0000      1.76
+++ session.c   2 Jul 2010 02:49:19 -0000       1.77
@@ -67,6 +67,8 @@
                fatal("gettimeofday failed");
        memcpy(&s->activity_time, &s->creation_time, sizeof s->activity_time);
 
+       s->cwd = xstrdup(cwd);
+
        s->curw = NULL;
        TAILQ_INIT(&s->lastw);
        RB_INIT(&s->windows);
@@ -141,6 +143,7 @@
        while (!RB_EMPTY(&s->windows))
                winlink_remove(&s->windows, RB_ROOT(&s->windows));
 
+       xfree(s->cwd);
        xfree(s->name);
 
        for (i = 0; i < ARRAY_LENGTH(&dead_sessions); i++) {

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.565
retrieving revision 1.566
diff -u -d -r1.565 -r1.566
--- tmux.h      2 Jul 2010 02:43:01 -0000       1.565
+++ tmux.h      2 Jul 2010 02:49:19 -0000       1.566
@@ -925,6 +925,7 @@
 
 struct session {
        char            *name;
+       char            *cwd;
 
        struct timeval   creation_time;
        struct timeval   activity_time;

Index: cmd-new-window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-new-window.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- cmd-new-window.c    22 Jun 2010 23:26:18 -0000      1.46
+++ cmd-new-window.c    2 Jul 2010 02:49:19 -0000       1.47
@@ -176,10 +176,13 @@
        cmd = data->cmd;
        if (cmd == NULL)
                cmd = options_get_string(&s->options, "default-command");
-       if (ctx->cmdclient == NULL || ctx->cmdclient->cwd == NULL)
-               cwd = options_get_string(&s->options, "default-path");
-       else
-               cwd = ctx->cmdclient->cwd;
+       cwd = options_get_string(&s->options, "default-path");
+       if (*cwd == '\0') {
+               if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
+                       cwd = ctx->cmdclient->cwd;
+               else
+                       cwd = s->cwd;
+       }
 
        if (idx == -1)
                idx = -1 - options_get_number(&s->options, "base-index");


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to