summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-05-03 14:36:08 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2008-05-03 14:36:08 +0800
commit4f2272fda63451a36a3133d17d493ac4e05034be (patch)
treeae3b49bca4745fb785184cac155969a7bff196b5 /src
parent[CD] Test __GLIBC__ instead of _GNU_SOURCE (diff)
downloaddash-4f2272fda63451a36a3133d17d493ac4e05034be.tar.gz
dash-4f2272fda63451a36a3133d17d493ac4e05034be.zip
[CD] Restored warning when getcwd fails
Somewhere along the lines the warning when getcwd fails went missing.
This patch restores it.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
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