Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Bug with :P modifier when current directory is the root
- X-seq: zsh-workers 40825
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Bug with :P modifier when current directory is the root
- Date: Fri, 10 Mar 2017 18:25:01 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:to:subject:mime-version; bh=yanwjz+FpY8poUIt+GQZGC0WozVRv1vfU21dWHFaPk4=; b=EoO/VFCYc3YjQlAXeN/mUS/6ZEn/a70VZrmQI0Z5zdrOtrp76jEplZ+IsPnlXS+duh OEVCmEDpMzJBs+/sYIV03S++NpmgtfpsLSxBOYD4g8hoHu3s4yhlPZR6UNKbQgzkCLrb UJMzsO+A6y7XjBQgU9j3dPrfd+iS6K/lA9DY0hoszw9HoaDRn198yIB4I+T0tiJOVmUe R46nv+EwfkHBMGpGnKVtUyzDz7i3CEMSmogI/6Iz1IxlxTLUDVNc6TNzWw0PpwqHFsu2 2osCtIgXsKgOKwEEl2hOZ5kFBKOKTwrSml5RlPgLRbggw3uFbSnWwGvUzy1B6lDBjKWy 4LYQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Debugging in another thread, I added this line to
_canonical_paths_add_paths --
: curpref is $curpref and :P is $curpref:P
and _complete_debug (with "$PWD" == "/") says
+_canonical_paths_add_paths:11> : curpref is m and :P is //m
I can't think of any case [*] where the :P modifier should add a double
leading slash.
[*] Except on weird OSs where you refer to auto-mount points with //host/
but that's definitely not the case here.
Does this need an extra test that (here[strlen(here)-1] != '/') or some
such, or are we safe enough this way? Can zgetcwd() ever return "//" or
"///" etc.?
diff --git a/Src/subst.c b/Src/subst.c
index 2214b3d..d68f16b 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[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[1])
+ *str = zhtricat(metafy(here, -1, META_HEAPDUP), "/", *str);
+ else
+ *str = dyncat(here, *str);
}
*str = xsymlink(*str, 1);
break;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author