mirror of
https://github.com/tmux/tmux.git
synced 2026-10-06 17:49:52 +00:00
Change to the new working directory even if getcwd fails, GitHub issue 5658.
This commit is contained in:
18
spawn.c
18
spawn.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: spawn.c,v 1.53 2026/09/21 12:43:36 nicm Exp $ */
|
||||
/* $OpenBSD: spawn.c,v 1.54 2026/10/02 13:20:42 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -467,14 +467,14 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
||||
new_wp->flags &= ~PANE_EMPTY;
|
||||
|
||||
/* Store current working directory and change to new one. */
|
||||
if (getcwd(path, sizeof path) != NULL) {
|
||||
if (chdir(new_wp->cwd) == 0)
|
||||
actual_cwd = new_wp->cwd;
|
||||
else if (home != NULL && chdir(home) == 0)
|
||||
actual_cwd = home;
|
||||
else if (chdir("/") == 0)
|
||||
actual_cwd = "/";
|
||||
}
|
||||
if (getcwd(path, sizeof path) == NULL)
|
||||
strlcpy(path, "/", sizeof path);
|
||||
if (chdir(new_wp->cwd) == 0)
|
||||
actual_cwd = new_wp->cwd;
|
||||
else if (home != NULL && chdir(home) == 0)
|
||||
actual_cwd = home;
|
||||
else if (chdir("/") == 0)
|
||||
actual_cwd = "/";
|
||||
|
||||
/* Fork the new process. */
|
||||
new_wp->pid = fdforkpty(ptm_fd, &new_wp->fd, new_wp->tty, NULL, &ws);
|
||||
|
||||
Reference in New Issue
Block a user