summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/cd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/sh/cd.c b/bin/sh/cd.c
index 6fb1039..1330c85 100644
--- a/bin/sh/cd.c
+++ b/bin/sh/cd.c
@@ -130,7 +130,12 @@ cdcmd(int argc, char **argv)
(path = bltinlookup("CDPATH", 1)) == NULL)
path = nullstr;
while ((p = padvance(&path, dest)) != NULL) {
- if (stat(p, &statb) >= 0 && S_ISDIR(statb.st_mode)) {
+ if (stat(p, &statb) < 0) {
+ if (errno != ENOENT)
+ errno1 = errno;
+ } else if (!S_ISDIR(statb.st_mode))
+ errno1 = ENOTDIR;
+ else {
if (!print) {
/*
* XXX - rethink
OpenPOWER on IntegriCloud