summaryrefslogtreecommitdiff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-07-15 08:43:25 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-07-15 08:43:25 +0000
commit351f6541e96e6eca2a55c4519ecc020be82e6ffa (patch)
tree6f10f773ca0efef352892f79cf8d84efa32a01d4 /Src/builtin.c
parent443a64d489394237a4eb7eca91ba81997fd691d7 (diff)
downloadzsh-351f6541e96e6eca2a55c4519ecc020be82e6ffa.tar.gz
zsh-351f6541e96e6eca2a55c4519ecc020be82e6ffa.zip
Eric Blake: 27151: cd handling with initial // for Cygwin
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 62c6e3c7d..162e7c254 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1029,17 +1029,19 @@ cd_try_chdir(char *pfix, char *dest, int hard)
/* handle directory prefix */
if (pfix && *pfix) {
- if (*pfix == '/')
+ if (*pfix == '/') {
#ifdef __CYGWIN__
/* NB: Don't turn "/"+"bin" into "//"+"bin" by mistake! "//bin" may *
* not be what user really wants (probably wants "/bin"), but *
* "//bin" could be valid too (see fixdir())! This is primarily for *
- * handling CDPATH correctly. */
- buf = tricat(pfix, ( pfix[1] == '\0' ? "" : "/" ), dest);
+ * handling CDPATH correctly. Likewise for "//"+"bin" not becoming *
+ * "///bin" (aka "/bin"). */
+ int root = pfix[1] == '\0' || (pfix[1] == '/' && pfix[2] == '\0');
+ buf = tricat(pfix, ( root ? "" : "/" ), dest);
#else
buf = tricat(pfix, "/", dest);
#endif
- else {
+ } else {
int pfl = strlen(pfix);
dlen = strlen(pwd);
@@ -1200,8 +1202,8 @@ fixdir(char *src)
/* compress multiple /es into single */
if (*src == '/') {
#ifdef __CYGWIN__
- /* allow leading // under cygwin */
- if (src == s0 && src[1] == '/')
+ /* allow leading // under cygwin, but /// still becomes / */
+ if (src == s0 && src[1] == '/' && src[2] != '/')
*dest++ = *src++;
#endif
*dest++ = *src++;