[BACK]Return to cmd-new-session.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/cmd-new-session.c between version 1.80 and 1.81

version 1.80, 2015/12/12 18:32:24 version 1.81, 2015/12/13 14:32:38
Line 41 
Line 41 
         "[-AdDEP] [-c start-directory] [-F format] [-n window-name] "          "[-AdDEP] [-c start-directory] [-F format] [-n window-name] "
         "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "          "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
         "[-y height] [command]",          "[-y height] [command]",
         CMD_STARTSERVER,          CMD_STARTSERVER|CMD_CANFAIL|CMD_SESSION_T,
         cmd_new_session_exec          cmd_new_session_exec
 };  };
   
Line 49 
Line 49 
         "has-session", "has",          "has-session", "has",
         "t:", 0, 0,          "t:", 0, 0,
         CMD_TARGET_SESSION_USAGE,          CMD_TARGET_SESSION_USAGE,
         0,          CMD_SESSION_T,
         cmd_new_session_exec          cmd_new_session_exec
 };  };
   
Line 57 
Line 57 
 cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)  cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
 {  {
         struct args             *args = self->args;          struct args             *args = self->args;
         struct client           *c = cmdq->client, *c0;          struct client           *c = cmdq->client;
         struct session          *s, *groupwith;          struct session          *s, *attach_sess;
           struct session          *groupwith = cmdq->state.tflag.s;
         struct window           *w;          struct window           *w;
         struct environ          *env;          struct environ          *env;
         struct termios           tio, *tiop;          struct termios           tio, *tiop;
Line 71 
Line 72 
         struct environ_entry    *envent;          struct environ_entry    *envent;
   
         if (self->entry == &cmd_has_session_entry) {          if (self->entry == &cmd_has_session_entry) {
                 if (cmd_find_session(cmdq, args_get(args, 't'), 0) == NULL)                  /*
                         return (CMD_RETURN_ERROR);                   * cmd_prepare() will fail if the session cannot be found,
                    * hence always return success here.
                    */
                 return (CMD_RETURN_NORMAL);                  return (CMD_RETURN_NORMAL);
         }          }
   
Line 87 
Line 90 
                         cmdq_error(cmdq, "bad session name: %s", newname);                          cmdq_error(cmdq, "bad session name: %s", newname);
                         return (CMD_RETURN_ERROR);                          return (CMD_RETURN_ERROR);
                 }                  }
                 if (session_find(newname) != NULL) {                  if ((attach_sess = session_find(newname)) != NULL) {
                         if (args_has(args, 'A')) {                          if (args_has(args, 'A')) {
                                 return (cmd_attach_session(cmdq, newname,                                  /*
                                    * This cmdq is now destined for
                                    * attach-session.  Because attach-session
                                    * will have already been prepared, copy this
                                    * session into its tflag so it can be used.
                                    */
                                   cmdq->state.tflag.s = attach_sess;
                                   return (cmd_attach_session(cmdq,
                                     args_has(args, 'D'), 0, NULL,                                      args_has(args, 'D'), 0, NULL,
                                     args_has(args, 'E')));                                      args_has(args, 'E')));
                         }                          }
Line 98 
Line 108 
                 }                  }
         }          }
   
         target = args_get(args, 't');          if ((target = args_get(args, 't')) == NULL)
         if (target != NULL) {  
                 groupwith = cmd_find_session(cmdq, target, 0);  
                 if (groupwith == NULL)  
                         return (CMD_RETURN_ERROR);  
         } else  
                 groupwith = NULL;                  groupwith = NULL;
   
         /* Set -d if no client. */          /* Set -d if no client. */
Line 120 
Line 125 
         to_free = NULL;          to_free = NULL;
         if (args_has(args, 'c')) {          if (args_has(args, 'c')) {
                 ft = format_create(cmdq, 0);                  ft = format_create(cmdq, 0);
                 format_defaults(ft, cmd_find_client(cmdq, NULL, 1), NULL, NULL,                  format_defaults(ft, c, NULL, NULL, NULL);
                     NULL);  
                 to_free = cwd = format_expand(ft, args_get(args, 'c'));                  to_free = cwd = format_expand(ft, args_get(args, 'c'));
                 format_free(ft);                  format_free(ft);
         } else if (c != NULL && c->session == NULL)          } else if (c != NULL && c->session == NULL)
                 cwd = c->cwd;                  cwd = c->cwd;
         else if ((c0 = cmd_find_client(cmdq, NULL, 1)) != NULL)  
                 cwd = c0->session->cwd;  
         else          else
                 cwd = ".";                  cwd = ".";
   
Line 193 
Line 195 
         /* Figure out the command for the new window. */          /* Figure out the command for the new window. */
         argc = -1;          argc = -1;
         argv = NULL;          argv = NULL;
         if (target == NULL && args->argc != 0) {          if (!args_has(args, 't') && args->argc != 0) {
                 argc = args->argc;                  argc = args->argc;
                 argv = args->argv;                  argv = args->argv;
         } else if (target == NULL) {          } else if (target == NULL) {
Line 245 
Line 247 
          * If a target session is given, this is to be part of a session group,           * If a target session is given, this is to be part of a session group,
          * so add it to the group and synchronize.           * so add it to the group and synchronize.
          */           */
         if (groupwith != NULL) {          if (args_has(args, 't')) {
                 session_group_add(groupwith, s);                  session_group_add(groupwith, s);
                 session_group_synchronize_to(s);                  session_group_synchronize_to(s);
                 session_select(s, RB_MIN(winlinks, &s->windows)->idx);                  session_select(s, RB_MIN(winlinks, &s->windows)->idx);
Line 285 
Line 287 
                         template = NEW_SESSION_TEMPLATE;                          template = NEW_SESSION_TEMPLATE;
   
                 ft = format_create(cmdq, 0);                  ft = format_create(cmdq, 0);
                 format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,                  format_defaults(ft, c, s, NULL, NULL);
                     NULL);  
   
                 cp = format_expand(ft, template);                  cp = format_expand(ft, template);
                 cmdq_print(cmdq, "%s", cp);                  cmdq_print(cmdq, "%s", cp);

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.81