summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-17 13:15:44 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-17 13:15:44 +0000
commit5231119bf4668c4c03a5dfd18d7d94d5160104e0 (patch)
tree4638f3e07aafe6267a8ef2fe56c11f1abd5d39f1
parenta7d9a9f977ac45e3464248c5a106d10c7cbf022e (diff)
do not treat symbolic links special; from cgd@netbsd.org; netbsd pr#1776
-rw-r--r--bin/sh/cd.c107
-rw-r--r--bin/sh/shell.h2
2 files changed, 5 insertions, 104 deletions
diff --git a/bin/sh/cd.c b/bin/sh/cd.c
index d3e77689e91..1a275d78949 100644
--- a/bin/sh/cd.c
+++ b/bin/sh/cd.c
@@ -118,124 +118,27 @@ cdcmd(argc, argv)
/*
- * Actually do the chdir. If the name refers to symbolic links, we
- * compute the actual directory name before doing the cd. In an
- * interactive shell, print the directory name if "print" is nonzero
- * or if the name refers to a symbolic link. We also print the name
- * if "/u/logname" was expanded in it, since this is similar to a
- * symbolic link. (The check for this breaks if the user gives the
- * cd command some additional, unused arguments.)
+ * Actually do the chdir. In an interactive shell, print the
+ * directory name if "print" is nonzero.
*/
-#if SYMLINKS == 0
STATIC int
docd(dest, print)
char *dest;
- {
- INTOFF;
- if (chdir(dest) < 0) {
- INTON;
- return -1;
- }
- updatepwd(dest);
- INTON;
- if (print && iflag)
- out1fmt("%s\n", stackblock());
- return 0;
-}
-
-#else
-
-
-
-STATIC int
-docd(dest, print)
- char *dest;
- int print;
{
- register char *p;
- register char *q;
- char *symlink;
- char *component;
- struct stat statb;
- int first;
- int i;
TRACE(("docd(\"%s\", %d) called\n", dest, print));
-
-top:
- cdcomppath = dest;
- STARTSTACKSTR(p);
- if (*dest == '/') {
- STPUTC('/', p);
- cdcomppath++;
- }
- first = 1;
- while ((q = getcomponent()) != NULL) {
- if (q[0] == '\0' || (q[0] == '.' && q[1] == '\0'))
- continue;
- if (! first)
- STPUTC('/', p);
- first = 0;
- component = q;
- while (*q)
- STPUTC(*q++, p);
- if (equal(component, ".."))
- continue;
- STACKSTRNUL(p);
- if (lstat(stackblock(), &statb) < 0)
- error("lstat %s failed", stackblock());
- if (!S_ISLNK(statb.st_mode))
- continue;
-
- /* Hit a symbolic link. We have to start all over again. */
- print = 1;
- STPUTC('\0', p);
- symlink = grabstackstr(p);
- i = (int)statb.st_size + 2; /* 2 for '/' and '\0' */
- if (cdcomppath != NULL)
- i += strlen(cdcomppath);
- p = stalloc(i);
- if (readlink(symlink, p, (int)statb.st_size) < 0) {
- error("readlink %s failed", stackblock());
- }
- if (cdcomppath != NULL) {
- p[(int)statb.st_size] = '/';
- scopy(cdcomppath, p + (int)statb.st_size + 1);
- } else {
- p[(int)statb.st_size] = '\0';
- }
- if (p[0] != '/') { /* relative path name */
- char *r;
- q = r = symlink;
- while (*q) {
- if (*q++ == '/')
- r = q;
- }
- *r = '\0';
- dest = stalloc(strlen(symlink) + strlen(p) + 1);
- scopy(symlink, dest);
- strcat(dest, p);
- } else {
- dest = p;
- }
- goto top;
- }
- STPUTC('\0', p);
- p = grabstackstr(p);
INTOFF;
- if (chdir(p) < 0) {
+ if (chdir(dest) < 0) {
INTON;
return -1;
}
- updatepwd(p);
+ updatepwd(dest);
INTON;
if (print && iflag)
- out1fmt("%s\n", p);
+ out1fmt("%s\n", stackblock());
return 0;
}
-#endif /* SYMLINKS */
-
/*
diff --git a/bin/sh/shell.h b/bin/sh/shell.h
index 31be7926f02..2cd6bf862d5 100644
--- a/bin/sh/shell.h
+++ b/bin/sh/shell.h
@@ -41,7 +41,6 @@
/*
* The follow should be set to reflect the type of system you have:
* JOBS -> 1 if you have Berkeley job control, 0 otherwise.
- * SYMLINKS -> 1 if your system includes symbolic links, 0 otherwise.
* SHORTNAMES -> 1 if your linker cannot handle long names.
* define BSD if you are running 4.2 BSD or later.
* define SYSV if you are running under System V.
@@ -54,7 +53,6 @@
#define JOBS 1
-#define SYMLINKS 1
#ifndef BSD
#define BSD 1
#endif