mirror of
https://github.com/tmux/tmux.git
synced 2026-10-11 21:14:21 +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>
|
* 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;
|
new_wp->flags &= ~PANE_EMPTY;
|
||||||
|
|
||||||
/* Store current working directory and change to new one. */
|
/* Store current working directory and change to new one. */
|
||||||
if (getcwd(path, sizeof path) != NULL) {
|
if (getcwd(path, sizeof path) == NULL)
|
||||||
if (chdir(new_wp->cwd) == 0)
|
strlcpy(path, "/", sizeof path);
|
||||||
actual_cwd = new_wp->cwd;
|
if (chdir(new_wp->cwd) == 0)
|
||||||
else if (home != NULL && chdir(home) == 0)
|
actual_cwd = new_wp->cwd;
|
||||||
actual_cwd = home;
|
else if (home != NULL && chdir(home) == 0)
|
||||||
else if (chdir("/") == 0)
|
actual_cwd = home;
|
||||||
actual_cwd = "/";
|
else if (chdir("/") == 0)
|
||||||
}
|
actual_cwd = "/";
|
||||||
|
|
||||||
/* Fork the new process. */
|
/* Fork the new process. */
|
||||||
new_wp->pid = fdforkpty(ptm_fd, &new_wp->fd, new_wp->tty, NULL, &ws);
|
new_wp->pid = fdforkpty(ptm_fd, &new_wp->fd, new_wp->tty, NULL, &ws);
|
||||||
|
|||||||
Reference in New Issue
Block a user