Check return value of chdir() to stop a silly warning with some

compilers, GitHub issue 2573.
This commit is contained in:
nicm
2021-02-19 09:09:16 +00:00
parent fb42ae3071
commit b04f8acb70
2 changed files with 8 additions and 8 deletions

View File

@@ -379,10 +379,10 @@ spawn_pane(struct spawn_context *sc, char **cause)
* Child process. Change to the working directory or home if that
* fails.
*/
if (chdir(new_wp->cwd) != 0) {
if ((tmp = find_home()) == NULL || chdir(tmp) != 0)
chdir("/");
}
if (chdir(new_wp->cwd) != 0 &&
((tmp = find_home()) == NULL || chdir(tmp) != 0) &&
chdir("/") != 0)
fatal("chdir failed");
/*
* Update terminal escape characters from the session if available and