X-Git-Url: https://rtime.felk.cvut.cz/gitweb/l4.git/blobdiff_plain/8fe9942cde59835eb3c3c6936d866dd3305582ef..003b628647705666de261350195da72a38f2c4d2:/l4/pkg/dash/contrib/src/cd.c diff --git a/l4/pkg/dash/contrib/src/cd.c b/l4/pkg/dash/contrib/src/cd.c index 377066468..2d9d4b521 100644 --- a/l4/pkg/dash/contrib/src/cd.c +++ b/l4/pkg/dash/contrib/src/cd.c @@ -37,6 +37,7 @@ #include #include #include +#include /* * The cd and pwd commands. @@ -106,7 +107,7 @@ cdcmd(int argc, char **argv) if (!dest) dest = nullstr; if (*dest == '/') - goto step7; + goto step6; if (*dest == '.') { c = dest[1]; dotdot: @@ -122,13 +123,8 @@ dotdot: } if (!*dest) dest = "."; - if (!(path = bltinlookup("CDPATH"))) { -step6: -step7: - p = dest; - goto docd; - } - do { + path = bltinlookup("CDPATH"); + while (path) { c = *path; p = padvance(&path, dest); if (stat(p, &statb) >= 0 && S_ISDIR(statb.st_mode)) { @@ -137,9 +133,15 @@ step7: docd: if (!docd(p, flags)) goto out; - break; + goto err; } - } while (path); + } + +step6: + p = dest; + goto docd; + +err: sh_error("can't cd to %s", dest); /* NOTREACHED */ out: