diff --git a/src/cd.c b/src/cd.c index a4e024d..be4d571 100644 --- a/src/cd.c +++ b/src/cd.c @@ -109,7 +109,7 @@ cdcmd(int argc, char **argv) } if (!dest) dest = nullstr; - if (*dest == '/') + if (*dest == '/' || strchr(dest, ':')) goto step6; if (*dest == '.') { c = dest[1]; @@ -210,19 +210,19 @@ updatepwd(const char *dir) cdcomppath = sstrdup(dir); STARTSTACKSTR(new); - if (*dir != '/') { + if (*dir != '/' && !strchr(dir, ':')) { if (curdir == nullstr) return 0; new = stputs(curdir, new); } new = makestrspace(strlen(dir) + 2, new); lim = stackblock() + 1; - if (*dir != '/') { + if (*dir != '/' && !strchr(dir, ':')) { if (new[-1] != '/') USTPUTC('/', new); if (new > lim && *lim == '/') lim++; - } else { + } else if (*dir == '/') { USTPUTC('/', new); cdcomppath++; if (dir[1] == '/' && dir[2] != '/') { diff --git a/src/exec.c b/src/exec.c index ec0eadd..9147735 100644 --- a/src/exec.c +++ b/src/exec.c @@ -193,7 +193,7 @@ padvance(const char **path, const char *name) if (*path == NULL) return NULL; start = *path; - for (p = start ; *p && *p != ':' && *p != '%' ; p++); + for (p = start ; *p && *p != ';' && *p != '%' ; p++); len = p - start + strlen(name) + 2; /* "2" is for '/' and '\0' */ while (stackblocksize() < len) growstackblock(); @@ -207,9 +207,9 @@ padvance(const char **path, const char *name) pathopt = NULL; if (*p == '%') { pathopt = ++p; - while (*p && *p != ':') p++; + while (*p && *p != ';') p++; } - if (*p == ':') + if (*p == ';') *path = p + 1; else *path = NULL; @@ -530,8 +530,8 @@ changepath(const char *newval) for (;;) { if (*old != *new) { firstchange = idx; - if ((*old == '\0' && *new == ':') - || (*old == ':' && *new == '\0')) + if ((*old == '\0' && *new == ';') + || (*old == ';' && *new == '\0')) firstchange++; old = new; /* ignore subsequent differences */ } @@ -539,7 +539,7 @@ changepath(const char *newval) break; if (*new == '%' && bltin < 0 && prefix(new + 1, "builtin")) bltin = idx; - if (*new == ':') { + if (*new == ';') { idx++; } new++, old++; diff --git a/src/redir.c b/src/redir.c index ba7e165..b55fdd5 100644 --- a/src/redir.c +++ b/src/redir.c @@ -390,15 +390,28 @@ RESET { * the original file dscriptor is not open. */ +int dup10(int fd) { + // XXX hack + int new_fd = dup(fd); + if (new_fd < 0) + return -1; + if (new_fd > 10) + return new_fd; + else { + int new_fd2 = dup10(new_fd); + close(new_fd); + return new_fd2; + } + +} + int savefd(int from, int ofd) { - return from; // FIXME -/* int newfd; int err; - newfd = fcntl(from, F_DUPFD, 10); + newfd = dup10(from); err = newfd < 0 ? errno : 0; if (err != EBADF) { close(ofd); @@ -409,7 +422,6 @@ savefd(int from, int ofd) } return newfd; -*/ }