about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-02-15 20:20:03 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2015-02-15 20:20:03 -0800
commit2335d6254815050d3a0ae9b5a8677ec2f567b631 (patch)
tree0f669da9e3557dadb99964e1a813e40dfb28ce1b /Src/builtin.c
parent2c13d9fb0da0ec513e577c2589ec545df665326e (diff)
downloadzsh-2335d6254815050d3a0ae9b5a8677ec2f567b631.tar.gz
zsh-2335d6254815050d3a0ae9b5a8677ec2f567b631.tar.xz
zsh-2335d6254815050d3a0ae9b5a8677ec2f567b631.zip
34551: Avoid adding an extra "/" to the target path in cd_try_chdir() when the current directory is "/"
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c6
1 files changed, 4 insertions, 2 deletions
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] = '/';