summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authornicm <nicm>2018-01-01 11:19:08 +0000
committernicm <nicm>2018-01-01 11:19:08 +0000
commitd17c90583a2cbbb15ec1a357380b0985e6472a5f (patch)
tree5e0fce407aba9d94b72c88a6b5e05b44b7311baf /client.c
parentfe26f977e6fe81c1bedf251cc1da6cf3792a9f97 (diff)
Prefer PWD for current directory if present in client, from Wei Zhao in
GitHub issue 1183.
Diffstat (limited to 'client.c')
-rw-r--r--client.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/client.c b/client.c
index 6feafc93..aa6b596f 100644
--- a/client.c
+++ b/client.c
@@ -279,10 +279,10 @@ client_main(struct event_base *base, int argc, char **argv, int flags)
client_peer = proc_add_peer(client_proc, fd, client_dispatch, NULL);
/* Save these before pledge(). */
- if ((cwd = getcwd(path, sizeof path)) == NULL) {
- if ((cwd = find_home()) == NULL)
- cwd = "/";
- }
+ if ((cwd = getenv("PWD")) == NULL &&
+ (cwd = getcwd(path, sizeof path)) == NULL &&
+ (cwd = find_home()) == NULL)
+ cwd = "/";
if ((ttynam = ttyname(STDIN_FILENO)) == NULL)
ttynam = "";