Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: more flexible cd builtin revised



> 	if (lchdir(buf, NULL, hard) && lchdir(dest, NULL, hard))

Yes, that makes more sense.

Index: Src/builtin.c
===================================================================
RCS file: /cvs/zsh/zsh/Src/builtin.c,v
retrieving revision 1.1.1.45
diff -u -r1.1.1.45 builtin.c
--- Src/builtin.c	1999/12/13 21:57:56	1.1.1.45
+++ Src/builtin.c	1999/12/15 18:35:49
@@ -951,8 +951,11 @@
     else
 	unmetafy(buf, &dlen);
 
-    if (lchdir(dest, NULL, hard))	/* Try plain relative first */
-    if (lchdir(buf, NULL, hard)) {
+    /* We try the full path first.  If that fails, try the
+     * argument to cd relatively.  This is useful if the cwd
+     * or a parent directory is renamed in the interim.
+     */
+    if (lchdir(buf, NULL, hard) && lchdir(dest, NULL, hard)) {
 	free(buf);
 	return NULL;
     }



Messages sorted by: Reverse Date, Date, Thread, Author