about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2017-03-11 14:39:17 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2017-03-11 14:40:12 -0800
commit420fc41b7cccab7f1ee07abab2cb7c72501cf91e (patch)
tree252077047003913b490cbaf253c34cc74fce8a59
parent5da6621ffe4047358bbcd4f5ee0e3a118e65de73 (diff)
downloadzsh-420fc41b7cccab7f1ee07abab2cb7c72501cf91e.tar.gz
zsh-420fc41b7cccab7f1ee07abab2cb7c72501cf91e.tar.xz
zsh-420fc41b7cccab7f1ee07abab2cb7c72501cf91e.zip
40832: fix $x:P when PWD=/
-rw-r--r--ChangeLog4
-rw-r--r--Src/subst.c12
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e72fb759..9744a1ee7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-03-11  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 40832: Src/subst.c: fix $x:P when PWD=/
+
 2017-03-11  John Leuenhagen  <john@zlima12.com>
 
 	* unposted (github pull request #15):
diff --git a/Src/subst.c b/Src/subst.c
index 2214b3d4f..e639c96a8 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -4336,7 +4336,11 @@ modify(char **str, char **ptr)
 			break;
 		    case 'P':
 			if (*copy != '/') {
-			    copy = zhtricat(metafy(zgetcwd(), -1, META_HEAPDUP), "/", copy);
+			    char *here = zgetcwd();
+			    if (here[strlen(here)-1] != '/')
+				copy = zhtricat(metafy(here, -1, META_HEAPDUP), "/", copy);
+			    else
+				copy = dyncat(here, copy);
 			}
 			copy = xsymlink(copy, 1);
 			break;
@@ -4418,7 +4422,11 @@ modify(char **str, char **ptr)
 		    break;
 		case 'P':
 		    if (**str != '/') {
-			*str = zhtricat(metafy(zgetcwd(), -1, META_HEAPDUP), "/", *str);
+			char *here = zgetcwd();
+			if (here[strlen(here)-1] != '/')
+			    *str = zhtricat(metafy(here, -1, META_HEAPDUP), "/", *str);
+			else
+			    *str = dyncat(here, *str);
 		    }
 		    *str = xsymlink(*str, 1);
 		    break;