summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/cd.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cd.c b/src/cd.c
index 73ccde0..624801d 100644
--- a/src/cd.c
+++ b/src/cd.c
@@ -52,6 +52,7 @@
 #include "error.h"
 #include "exec.h"
 #include "redir.h"
+#include "main.h"
 #include "mystring.h"
 #include "show.h"
 #include "cd.h"
@@ -251,11 +252,18 @@ getpwd()
 {
 #ifdef __GLIBC__
 	char *dir = getcwd(0, 0);
-	return dir ? dir : nullstr;
+
+	if (dir)
+		return dir;
 #else
 	char buf[PATH_MAX];
-	return getcwd(buf, sizeof(buf)) ? savestr(buf) : nullstr;
+
+	if (getcwd(buf, sizeof(buf))
+		return savestr(buf);
 #endif
+
+	sh_warnx("getcwd() failed: %s", strerror(errno));
+	return nullstr;
 }
 
 int