[BACK]Return to spawn.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/spawn.c between version 1.29 and 1.30

version 1.29, 2021/08/23 11:04:21 version 1.30, 2022/05/30 13:06:41
Line 211 
Line 211 
         struct window_pane       *new_wp;          struct window_pane       *new_wp;
         struct environ           *child;          struct environ           *child;
         struct environ_entry     *ee;          struct environ_entry     *ee;
         char                    **argv, *cp, **argvp, *argv0, *cwd;          char                    **argv, *cp, **argvp, *argv0, *cwd, *new_cwd;
         const char               *cmd, *tmp;          const char               *cmd, *tmp;
         int                       argc;          int                       argc;
         u_int                     idx;          u_int                     idx;
Line 227 
Line 227 
          * Work out the current working directory. If respawning, use           * Work out the current working directory. If respawning, use
          * the pane's stored one unless specified.           * the pane's stored one unless specified.
          */           */
         if (sc->cwd != NULL)          if (sc->cwd != NULL) {
                 cwd = format_single(item, sc->cwd, c, target->s, NULL, NULL);                  cwd = format_single(item, sc->cwd, c, target->s, NULL, NULL);
         else if (~sc->flags & SPAWN_RESPAWN)                  if (*cwd != '/') {
                           xasprintf(&new_cwd, "%s/%s", server_client_get_cwd(c,
                               target->s), cwd);
                           free(cwd);
                           cwd = new_cwd;
                   }
           } else if (~sc->flags & SPAWN_RESPAWN)
                 cwd = xstrdup(server_client_get_cwd(c, target->s));                  cwd = xstrdup(server_client_get_cwd(c, target->s));
         else          else
                 cwd = NULL;                  cwd = NULL;
Line 337 
Line 343 
                 log_debug("%s: cmd=%s", __func__, cp);                  log_debug("%s: cmd=%s", __func__, cp);
                 free(cp);                  free(cp);
         }          }
         if (cwd != NULL)          log_debug("%s: cwd=%s", __func__, new_wp->cwd);
                 log_debug("%s: cwd=%s", __func__, cwd);  
         cmd_log_argv(new_wp->argc, new_wp->argv, "%s", __func__);          cmd_log_argv(new_wp->argc, new_wp->argv, "%s", __func__);
         environ_log(child, "%s: environment ", __func__);          environ_log(child, "%s: environment ", __func__);
   
Line 384 
Line 389 
          * Child process. Change to the working directory or home if that           * Child process. Change to the working directory or home if that
          * fails.           * fails.
          */           */
         if (chdir(new_wp->cwd) != 0 &&          if (chdir(new_wp->cwd) == 0)
             ((tmp = find_home()) == NULL || chdir(tmp) != 0) &&                  environ_set(child, "PWD", 0, "%s", new_wp->cwd);
             chdir("/") != 0)          else if ((tmp = find_home()) != NULL || chdir(tmp) == 0)
                   environ_set(child, "PWD", 0, "%s", tmp);
           else if (chdir("/") == 0)
                   environ_set(child, "PWD", 0, "/");
           else
                 fatal("chdir failed");                  fatal("chdir failed");
   
         /*          /*

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30