summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/cd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/sh/cd.c b/bin/sh/cd.c
index 2cd9daf..b1b0fc0 100644
--- a/bin/sh/cd.c
+++ b/bin/sh/cd.c
@@ -123,7 +123,10 @@ cdcmd(int argc, char **argv)
else
dest = ".";
}
- if (*dest == '/' || (path = bltinlookup("CDPATH", 1)) == NULL)
+ if (dest[0] == '/' ||
+ (dest[0] == '.' && (dest[1] == '/' || dest[1] == '\0')) ||
+ (dest[0] == '.' && dest[1] == '.' && (dest[2] == '/' || dest[2] == '\0')) ||
+ (path = bltinlookup("CDPATH", 1)) == NULL)
path = nullstr;
while ((p = padvance(&path, dest)) != NULL) {
if (stat(p, &statb) >= 0 && S_ISDIR(statb.st_mode)) {
OpenPOWER on IntegriCloud