summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-05-07 09:38:49 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-05-07 09:38:49 +0000
commit4f9580ec039ef11093791cff7263dcb06614045e (patch)
treed8435ade739928e115a2cfd3c785a78228cf8fc0 /Src
parentbd6c1364dfbb1552b18271586cab5c1a41471a6a (diff)
downloadzsh-4f9580ec039ef11093791cff7263dcb06614045e.tar.gz
zsh-4f9580ec039ef11093791cff7263dcb06614045e.tar.xz
zsh-4f9580ec039ef11093791cff7263dcb06614045e.zip
18508: quoting of separator in ${foo//../..} was buggy
Diffstat (limited to 'Src')
-rw-r--r--Src/subst.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 5396cdf6c..dc5044959 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1437,15 +1437,20 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 	     * If there isn't one, we're just going to delete that,
 	     * i.e. replace it with an empty string.
 	     *
-	     * This allows quotation of the slash with '\\/'. Why
-	     * two?  Well, for a non-quoted string we can check for
-	     * Bnull+/, which is what you get from `\/', but inside
-	     * double quotes the Bnull isn't there, so it's not
-	     * consistent.
+	     * We used to use double backslashes to quote slashes,
+	     * but actually that was buggy and using a single backslash
+	     * is easier and more obvious.
 	     */
 	    for (ptr = s; (c = *ptr) && c != '/'; ptr++)
-		if (c == '\\' && ptr[1] == '/')
-		    chuck(ptr);
+	    {
+		if ((c == Bnull || c == '\\') && ptr[1])
+		{
+		    if (ptr[1] == '/')
+			chuck(ptr);
+		    else
+			ptr++;
+		}
+	    }
 	    replstr = (*ptr && ptr[1]) ? ptr+1 : "";
 	    *ptr = '\0';
 	}