From 4f2272fda63451a36a3133d17d493ac4e05034be Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Sat, 3 May 2008 14:36:08 +0800 Subject: [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 --- src/cd.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') 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 -- cgit 1.4.1