[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>
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 @@
{
#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