From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: a bug of zsh
Date: Thu, 29 Sep 2016 21:29:43 -0700 [thread overview]
Message-ID: <160929212943.ZM28332@torch.brasslantern.com> (raw)
In-Reply-To: <20160929092357.6ebb6463@pwslap01u.europe.root.pri>
On Sep 29, 9:23am, Peter Stephenson wrote:
} Subject: Re: a bug of zsh
}
} % ./foo
} % pwd
} /export/home/pws/tmp/foo
} % rmdir ../foo
} % pwd
} /export/home/pws/tmp/foo # cd .. still works here
} % cd .
} % pwd
} . # but now "cd .." would require chase_dots
} %
}
} That seems a reasonable minimal fix. I haven't looked at the code.
Try it this way?
diff --git a/Src/builtin.c b/Src/builtin.c
index c78fd9b..60dc07f 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1273,7 +1273,23 @@ fixdir(char *src)
#ifdef __CYGWIN__
char *s0 = src;
#endif
- int ret = 0;
+ /* This function is always called with n path containing at
+ * least one slash, either because one was input by the user or
+ * because the caller has prepended either pwd or a cdpath dir.
+ * If asked to make a relative change and pwd is set to ".",
+ * the current directory has been removed out from under us,
+ * so force links to be chased.
+ *
+ * Ordinarily we can't get here with "../" as the first component
+ * but handle the silly special case of ".." in cdpath.
+ *
+ * Order of comparisons here looks funny, but it short-circuits
+ * most rapidly in the event of a false condition. Set to 2
+ * here so we still obey the (lack of) CHASEDOTS option after
+ * the first "../" is preserved (test chasedots > 1 below).
+ */
+ int chasedots = (src[0] == '.' && pwd[0] == '.' && pwd[1] == '\0' &&
+ (src[1] == '/' || (src[1] == '.' && src[2] == '/'))) * 2;
/*** if have RFS superroot directory ***/
#ifdef HAVE_SUPERROOT
@@ -1305,12 +1321,12 @@ fixdir(char *src)
while (dest > d0 + 1 && dest[-1] == '/')
dest--;
*dest = '\0';
- return ret;
+ return chasedots;
}
if (src[0] == '.' && src[1] == '.' &&
(src[2] == '\0' || src[2] == '/')) {
- if (isset(CHASEDOTS)) {
- ret = 1;
+ if (isset(CHASEDOTS) || chasedots > 1) {
+ chasedots = 1;
/* and treat as normal path segment */
} else {
if (dest > d0 + 1) {
@@ -1348,6 +1364,7 @@ fixdir(char *src)
dest[-1] = *src++ ^ 32;
}
}
+ /* unreached */
}
/**/
prev parent reply other threads:[~2016-09-30 4:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20160928140702eucas1p295fe6131e7ec88107a118fa9bbcbec7e@eucas1p2.samsung.com>
2016-09-28 14:06 ` ZiHan Zheng
2016-09-28 15:04 ` Peter Stephenson
2016-09-28 15:28 ` Mikael Magnusson
2016-09-28 16:07 ` Peter Stephenson
2016-09-28 19:10 ` Bart Schaefer
2016-09-29 8:23 ` Peter Stephenson
2016-09-30 4:29 ` Bart Schaefer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=160929212943.ZM28332@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).