From 6e77f38b925e3f37dc69b26efd6173df7281bbe8 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 7 May 2003 09:41:56 +0000 Subject: 18508: quoting of separator in ${foo//../..} was buggy --- Src/subst.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'Src') diff --git a/Src/subst.c b/Src/subst.c index 3533c1417..256e6d032 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -1366,15 +1366,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'; } -- cgit 1.4.1