Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: erroneous completion when using {}
- X-seq: zsh-workers 12113
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: Re: erroneous completion when using {}
- Date: Thu, 29 Jun 2000 08:57:46 +0200 (MET DST)
- In-reply-to: Sven Wischnowsky's message of Wed, 28 Jun 2000 11:22:20 +0200 (MET DST)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I wrote:
> Jan Fedak wrote:
>
> > When I use {} in a glob pattern like this:
> >
> > $ cat some/path/{directory\ 1, directory\ 2,_
> > ^
> > cursor :)
> >
> > and hit tab, my precious backslashes get lost:
> >
> > $ cat some/path/{directory 1,directory 2,directory\
>
> Oh, this is ugly. The problem is this: the completion code gets the
> line tokenized, where the backslashes are turned int Bnull tokens. It
> has to remove them for normal completion. After that comes the code
> that looks for brace expansions, so that can't put the backslashes
> back because it can't find where they were. Doing the brace expansion
> stuff before removing the Null tokens won't work either because the
> brace expansion code has to remove the `{foo,' things from the string.
>
> And just quoting the strings the brace expansion code removes won't
> work either because of `{{a,b},' (the braces of `{a,b}' would be
> quoted). So we either need a special quoting function or a good idea.
I was talking nonsense (thank god): bslashquote() is clever enough to
do the right thing with a tokenized string.
There is also a hunk for _expand, because that insisted on `expanding'
`a\ ' to `a '.
Bye
Sven
Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.20
diff -u -r1.20 _expand
--- Completion/Core/_expand 2000/06/21 08:05:28 1.20
+++ Completion/Core/_expand 2000/06/29 06:57:18
@@ -59,8 +59,9 @@
zstyle -T ":completion:${curcontext}:" substitute; then
[[ ! -o ignorebraces && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]] &&
eval exp\=\( ${${(q)exp}:gs/\\{/\{/:gs/\\}/\}/} \)
- exp=( ${(e)exp//\\[
-]/ } )
+ exp=( ${${(e)exp//\\[
+]/ }//(#b)([
+])/\\$match[1]} )
else
exp=( ${exp:s/\\\$/\$} )
fi
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.17
diff -u -r1.17 zle_tricky.c
--- Src/Zle/zle_tricky.c 2000/06/26 08:20:34 1.17
+++ Src/Zle/zle_tricky.c 2000/06/29 06:57:18
@@ -1464,11 +1464,12 @@
lastbrbeg = new;
new->next = NULL;
- new->str = ztrduppfx(bbeg, len);
+ new->str = dupstrpfx(bbeg, len);
+ new->str = ztrdup(bslashquote(new->str, NULL, instring));
untokenize(new->str);
new->pos = begi;
*dbeg = '\0';
- new->qpos = strlen(quotename(predup, NULL));
+ new->qpos = strlen(bslashquote(predup, NULL, instring));
*dbeg = '{';
i -= len;
boffs -= len;
@@ -1511,11 +1512,12 @@
brbeg = new;
lastbrbeg = new;
- new->str = ztrduppfx(bbeg, len);
+ new->str = dupstrpfx(bbeg, len);
+ new->str = ztrdup(bslashquote(new->str, NULL, instring));
untokenize(new->str);
new->pos = begi;
*dbeg = '\0';
- new->qpos = strlen(quotename(predup, NULL));
+ new->qpos = strlen(bslashquote(predup, NULL, instring));
*dbeg = '{';
i -= len;
boffs -= len;
@@ -1547,7 +1549,8 @@
new->next = brend;
brend = new;
- new->str = ztrduppfx(bbeg, len);
+ new->str = dupstrpfx(bbeg, len);
+ new->str = ztrdup(bslashquote(new->str, NULL, instring));
untokenize(new->str);
new->pos = dp - predup - len + 1;
new->qpos = len;
@@ -1575,11 +1578,12 @@
brbeg = new;
lastbrbeg = new;
- new->str = ztrduppfx(bbeg, len);
+ new->str = dupstrpfx(bbeg, len);
+ new->str = ztrdup(bslashquote(new->str, NULL, instring));
untokenize(new->str);
new->pos = begi;
*dbeg = '\0';
- new->qpos = strlen(quotename(predup, NULL));
+ new->qpos = strlen(bslashquote(predup, NULL, instring));
*dbeg = '{';
boffs -= len;
strcpy(dbeg, dbeg + len);
@@ -1594,7 +1598,7 @@
p = bp->pos;
l = bp->qpos;
bp->pos = strlen(predup + p + l);
- bp->qpos = strlen(quotename(predup + p + l, NULL));
+ bp->qpos = strlen(bslashquote(predup + p + l, NULL, instring));
strcpy(predup + p, predup + p + l);
}
}
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author