zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: more flexible cd builtin
@ 1999-12-13 21:56 Clint Adams
  1999-12-15 17:09 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Clint Adams @ 1999-12-13 21:56 UTC (permalink / raw)
  To: zsh-workers

If the current directory is renamed, zsh's cd will fail because
it's attempting to change to the full path which no longer exists.
This allows one to cd to a subdirectory successfully.  This is
incomplete; `pwd` will become correct, but $PWD will not.

Index: Src/builtin.c
===================================================================
RCS file: /cvs/zsh/zsh/Src/builtin.c,v
retrieving revision 1.1.1.44
diff -u -r1.1.1.44 builtin.c
--- Src/builtin.c	1999/12/10 21:40:57	1.1.1.44
+++ Src/builtin.c	1999/12/13 21:51:42
@@ -951,6 +951,7 @@
     else
 	unmetafy(buf, &dlen);
 
+    if (lchdir(dest, NULL, hard))	/* Try plain relative first */
     if (lchdir(buf, NULL, hard)) {
 	free(buf);
 	return NULL;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: more flexible cd builtin
  1999-12-13 21:56 PATCH: more flexible cd builtin Clint Adams
@ 1999-12-15 17:09 ` Bart Schaefer
  1999-12-15 18:38   ` PATCH: more flexible cd builtin revised Clint Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 1999-12-15 17:09 UTC (permalink / raw)
  To: zsh-workers

On Dec 13,  4:56pm, Clint Adams wrote:
} Subject: PATCH: more flexible cd builtin
}
} +    if (lchdir(dest, NULL, hard))	/* Try plain relative first */
}      if (lchdir(buf, NULL, hard)) {

Should that at least be in the other order?  That is,

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

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* PATCH: more flexible cd builtin revised
  1999-12-15 17:09 ` Bart Schaefer
@ 1999-12-15 18:38   ` Clint Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Clint Adams @ 1999-12-15 18:38 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

> 	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;
     }


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-12-15 18:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-13 21:56 PATCH: more flexible cd builtin Clint Adams
1999-12-15 17:09 ` Bart Schaefer
1999-12-15 18:38   ` PATCH: more flexible cd builtin revised Clint Adams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).