mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 10:08:47 +00:00
If getcwd() fails, use the user's home directory, or /, instead of failing with
an error.
This commit is contained in:
parent
bfa46e8f91
commit
f17a5f1e82
9
tmux.c
9
tmux.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: tmux.c,v 1.10 2009/06/25 06:40:25 nicm Exp $ */
|
/* $OpenBSD: tmux.c,v 1.11 2009/06/25 06:54:32 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -387,8 +387,11 @@ main(int argc, char **argv)
|
|||||||
&global_options, "default-command", "exec %s -l", shell);
|
&global_options, "default-command", "exec %s -l", shell);
|
||||||
|
|
||||||
if (getcwd(cwd, sizeof cwd) == NULL) {
|
if (getcwd(cwd, sizeof cwd) == NULL) {
|
||||||
log_warn("getcwd");
|
pw = getpwuid(getuid());
|
||||||
exit(1);
|
if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
|
||||||
|
strlcpy(cwd, pw->pw_dir, sizeof cwd);
|
||||||
|
else
|
||||||
|
strlcpy(cwd, "/", sizeof cwd);
|
||||||
}
|
}
|
||||||
options_set_string(&global_options, "default-path", "%s", cwd);
|
options_set_string(&global_options, "default-path", "%s", cwd);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user