about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/builtin.c6
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5307eaa6d..c389b936d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-15  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 34551: Src/builtin.c: Avoid adding an extra "/" to the
+	target path in cd_try_chdir() when the current directory is "/"
+
 2015-02-14  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* 34543: Src/input.c, Src/lex.c: Fix crash on garbage bytes
diff --git a/Src/builtin.c b/Src/builtin.c
index c4e4b94fd..614b17d7e 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1093,9 +1093,11 @@ cd_try_chdir(char *pfix, char *dest, int hard)
 	} else {
 	    int pfl = strlen(pfix);
 	    dlen = strlen(pwd);
-
+	    if (dlen == 1 && *pwd == '/')
+		dlen = 0;
 	    buf = zalloc(dlen + pfl + strlen(dest) + 3);
-	    strcpy(buf, pwd);
+	    if (dlen)
+		strcpy(buf, pwd);
 	    buf[dlen] = '/';
 	    strcpy(buf + dlen + 1, pfix);
 	    buf[dlen + 1 + pfl] = '/';