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

Diff for /src/usr.bin/tmux/cmd-respawn-pane.c between version 1.27 and 1.28

version 1.27, 2019/03/12 11:16:50 version 1.28, 2019/04/17 14:37:48
Line 20 
Line 20 
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <stdlib.h>  #include <stdlib.h>
 #include <unistd.h>  #include <string.h>
   
 #include "tmux.h"  #include "tmux.h"
   
Line 36 
Line 36 
   
         .args = { "c:kt:", 0, -1 },          .args = { "c:kt:", 0, -1 },
         .usage = "[-c start-directory] [-k] " CMD_TARGET_PANE_USAGE          .usage = "[-c start-directory] [-k] " CMD_TARGET_PANE_USAGE
                  " [command]",                   " [command]",
   
         .target = { 't', CMD_FIND_PANE, 0 },          .target = { 't', CMD_FIND_PANE, 0 },
   
Line 48 
Line 48 
 cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)  cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
 {  {
         struct args             *args = self->args;          struct args             *args = self->args;
           struct spawn_context     sc;
           struct session          *s = item->target.s;
         struct winlink          *wl = item->target.wl;          struct winlink          *wl = item->target.wl;
         struct window           *w = wl->window;  
         struct window_pane      *wp = item->target.wp;          struct window_pane      *wp = item->target.wp;
         struct client           *c = cmd_find_client(item, NULL, 1);          char                    *cause = NULL;
         struct session          *s = item->target.s;  
         struct environ          *env;  
         const char              *path = NULL, *cp;  
         char                    *cause, *cwd = NULL;  
         u_int                    idx;  
         struct environ_entry    *envent;  
   
         if (!args_has(self->args, 'k') && wp->fd != -1) {          memset(&sc, 0, sizeof sc);
                 if (window_pane_index(wp, &idx) != 0)          sc.item = item;
                         fatalx("index not found");          sc.s = s;
                 cmdq_error(item, "pane still active: %s:%d.%u",          sc.wl = wl;
                     s->name, wl->idx, idx);  
                 return (CMD_RETURN_ERROR);  
         }  
   
         window_pane_reset_mode_all(wp);          sc.wp0 = wp;
         screen_reinit(&wp->base);          sc.lc = NULL;
         input_init(wp);  
   
         if (item->client != NULL && item->client->session == NULL)          sc.name = NULL;
                 envent = environ_find(item->client->environ, "PATH");          sc.argc = args->argc;
         else          sc.argv = args->argv;
                 envent = environ_find(s->environ, "PATH");  
         if (envent != NULL)  
                 path = envent->value;  
   
         if ((cp = args_get(args, 'c')) != NULL)          sc.idx = -1;
                 cwd = format_single(item, cp, c, s, NULL, NULL);          sc.cwd = args_get(args, 'c');
   
         env = environ_for_session(s, 0);          sc.flags = SPAWN_RESPAWN;
         if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, cwd, env,          if (args_has(args, 'k'))
             s->tio, &cause) != 0) {                  sc.flags |= SPAWN_KILL;
   
           if (spawn_pane(&sc, &cause) == NULL) {
                 cmdq_error(item, "respawn pane failed: %s", cause);                  cmdq_error(item, "respawn pane failed: %s", cause);
                 free(cause);                  free(cause);
                 environ_free(env);  
                 free(cwd);  
                 return (CMD_RETURN_ERROR);                  return (CMD_RETURN_ERROR);
         }          }
         environ_free(env);  
         free(cwd);  
   
         wp->flags |= PANE_REDRAW;          wp->flags |= PANE_REDRAW;
         server_status_window(w);          server_status_window(wp->window);
   
         return (CMD_RETURN_NORMAL);          return (CMD_RETURN_NORMAL);
 }  }

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28