[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cd w/o cdpath
I think that prim_cd() doesn't have the ability to cd to a directory within
the current directory, by default. Only works if you make a cdpath with "."
in it. My solution was to add "." as an implicit cdpath member, but perhaps
there would be better ways to do it.
(Something I found in the source: there are subscript ranges - so I think
"shift" is now "* = $*(2 ... $#*)". That's nice. It would also be
interesting to be able to assign to a list, so "x = $1; shift" would
be "(x *) = $*", with the usual result of assigning one value to each
identifier except the last, which would get all remaining values; any
excess identifiers would get nil.)
Donn Cave, University Computing Services, University of Washington
donn@cac.washington.edu
-------------------------------
--- prim-etc.c Wed Oct 14 13:10:33 1992
***************
*** 200,205 ****
--- 200,206 ----
return true;
}
if (list->next == NULL) {
+ register int cdpath_has_null = 0;
char *name = getstr(list->term);
if (isabsolute(name) || streq(name, ".") || streq(name, ".."))
if (chdir(name) == -1)
***************
*** 220,227 ****
testlen = pathlen;
test = erealloc(test, testlen);
}
! if (*dir == '\0')
strcpy(test, name);
else {
strcpy(test, dir);
if (!streq(test, "/")) /* "//" is special to POSIX */
--- 221,230 ----
testlen = pathlen;
test = erealloc(test, testlen);
}
! if (*dir == '\0') {
! cdpath_has_null = 1;
strcpy(test, name);
+ }
else {
strcpy(test, dir);
if (!streq(test, "/")) /* "//" is special to POSIX */
***************
*** 236,242 ****
}
}
RefEnd(path);
! fail("cd %s: directory not found", name);
}
}
fail("usage: cd [directory]");
--- 239,250 ----
}
}
RefEnd(path);
! if (cdpath_has_null || chdir(name) < 0) {
! fail("cd %s: directory not found", name);
! }
! else {
! return true;
! }
}
}
fail("usage: cd [directory]");