* Strange bug when completing [ in file names
@ 2005-01-16 22:22 Tobias Gruetzmacher
2005-01-17 4:41 ` Bart Schaefer
2005-01-20 11:05 ` Oliver Kiddle
0 siblings, 2 replies; 7+ messages in thread
From: Tobias Gruetzmacher @ 2005-01-16 22:22 UTC (permalink / raw)
To: zsh-workers
Hi,
I have a very strange problem when completing files in directories under
my home directory. The problem only occours when I start the file name
with ~ and have a [ somewhere in the file name. Some short test case:
$ cd
$ mkdir testcase
$ touch testcase/file\[stuff{1,2,3,4,5}
$ ls ~/testcase/<TAB>
Now the following happens:
1. zsh inserts file\[stuff and stops - OK
2. I press <TAB> another time because I still can't remember the names
of the files, zsh changes the output to the following:
$ ls /home/tobias/testcase/file\[stuff
---- all expansions
/home/tobias/testcase/file\[stuff
---- original
~/testcase/file\[stuff
Now what has happened here? Can anyone give me a clue? I have the
impression that worked in an older version of zsh, but I can't remember.
If that is relevant I will try with older versions.
Using zsh 4.2.3 on Debian GNU/Linux sid(unstable).
Greetings Tobi
--
GPG-Key 0xE2BEA341 - signed/encrypted mail preferred
My, oh so small, homepage: http://portfolio16.de/
http://www.fli4l.de/ - ISDN- & DSL-Router on one disk!
Registered FLI4L-User #00000003
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange bug when completing [ in file names
2005-01-16 22:22 Strange bug when completing [ in file names Tobias Gruetzmacher
@ 2005-01-17 4:41 ` Bart Schaefer
2005-01-17 14:44 ` Tobias Gruetzmacher
2005-01-20 11:05 ` Oliver Kiddle
1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2005-01-17 4:41 UTC (permalink / raw)
To: zsh-workers
On Jan 16, 11:22pm, Tobias Gruetzmacher wrote:
}
} $ ls /home/tobias/testcase/file\[stuff
} ---- all expansions
What's the value of your completer style?
My guess is that the _expand completer is spotting the '[' and deciding
that it's a pattern character, and therefore generating matches, so none
of the completers that are listed after _expand gets a chance to run.
This is different in 4.2.x and 4.0.x, but I'm not sure if the difference
is because of a change in the default behavior of the accept-exact style,
or if it's an unintentional consequence of a change in parameter expansion.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange bug when completing [ in file names
2005-01-17 4:41 ` Bart Schaefer
@ 2005-01-17 14:44 ` Tobias Gruetzmacher
2005-01-18 0:33 ` Bart Schaefer
0 siblings, 1 reply; 7+ messages in thread
From: Tobias Gruetzmacher @ 2005-01-17 14:44 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer schrieb:
> On Jan 16, 11:22pm, Tobias Gruetzmacher wrote:
> }
> } $ ls /home/tobias/testcase/file\[stuff
> } ---- all expansions
>
> What's the value of your completer style?
You mean this:
zstyle ':completion:*' completer _expand _complete _correct _approximate
> My guess is that the _expand completer is spotting the '[' and deciding
> that it's a pattern character, and therefore generating matches, so none
> of the completers that are listed after _expand gets a chance to run.
Hmm, sounds like a could work around this thing by swapping _expand and
_complete? I tried that and it seems to work right now, but I don't know
what implications on other aspects of the completion system that has...
Greetings Tobi
--
GPG-Key 0xE2BEA341 - signed/encrypted mail preferred
My, oh so small, homepage: http://portfolio16.de/
http://www.fli4l.de/ - ISDN- & DSL-Router on one disk!
Registered FLI4L-User #00000003
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange bug when completing [ in file names
2005-01-17 14:44 ` Tobias Gruetzmacher
@ 2005-01-18 0:33 ` Bart Schaefer
0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2005-01-18 0:33 UTC (permalink / raw)
To: zsh-workers
On Jan 17, 3:44pm, Tobias Gruetzmacher wrote:
} Subject: Re: Strange bug when completing [ in file names
}
} Hmm, sounds like a could work around this thing by swapping _expand and
} _complete?
Yes, although that may mean you don't get expansions in all the cases
you might want.
I think there's a bug in _expand, because the value of the accept-exact
style doesn't seem to have any effect on this particular example, and it
should.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange bug when completing [ in file names
2005-01-16 22:22 Strange bug when completing [ in file names Tobias Gruetzmacher
2005-01-17 4:41 ` Bart Schaefer
@ 2005-01-20 11:05 ` Oliver Kiddle
2005-01-20 15:29 ` Bart Schaefer
1 sibling, 1 reply; 7+ messages in thread
From: Oliver Kiddle @ 2005-01-20 11:05 UTC (permalink / raw)
To: Tobias Gruetzmacher; +Cc: zsh-workers
On 16 Jan, Tobias Gruetzmacher wrote:
> I have a very strange problem when completing files in directories under
> my home directory. The problem only occours when I start the file name
> with ~ and have a [ somewhere in the file name. Some short test case:
Looks like the handling of the suffix style in _expand is seeing the `['
character and assuming that we have a glob pattern in there. But we
don't: the `[' is quoted. The following patch fixes it.
Oliver
Index: Completion/Base/Completer/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_expand,v
retrieving revision 1.9
diff -u -r1.9 _expand
--- Completion/Base/Completer/_expand 7 Aug 2004 15:27:29 -0000 1.9
+++ Completion/Base/Completer/_expand 20 Jan 2005 11:03:32 -0000
@@ -35,7 +35,7 @@
zstyle -T ":completion:${curcontext}:" suffix &&
[[ "$word" = (\~*/*|*\$(|[=~#^+])[a-zA-Z0-9_\[\]]##[^a-zA-Z0-9_\[\]]|*\$\{*\}?) &&
- "${(e)word}" != *[][^*?\(\)\<\>\{\}\|]* ]] &&
+ "${(e)word}" != *[^\\][][^*?\(\)\<\>\{\}\|]* ]] &&
return 1
zstyle -s ":completion:${curcontext}:" accept-exact tmp ||
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange bug when completing [ in file names
2005-01-20 11:05 ` Oliver Kiddle
@ 2005-01-20 15:29 ` Bart Schaefer
2005-01-20 18:04 ` Oliver Kiddle
0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2005-01-20 15:29 UTC (permalink / raw)
To: Oliver Kiddle; +Cc: zsh-workers
On Jan 20, 12:05pm, Oliver Kiddle wrote:
} Subject: Re: Strange bug when completing [ in file names
}
} the `[' is quoted. The following patch fixes it.
}
} + "${(e)word}" != *[^\\][][^*?\(\)\<\>\{\}\|]* ]] &&
Doesn't that need to be
(#s)(*[^\\]|)[^*?\(\)\<\>\{\}\|]*
or something similar, so that a word beginning with "[[" can match?
E.g. a word beginning with the pattern [[:alpha:].]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange bug when completing [ in file names
2005-01-20 15:29 ` Bart Schaefer
@ 2005-01-20 18:04 ` Oliver Kiddle
0 siblings, 0 replies; 7+ messages in thread
From: Oliver Kiddle @ 2005-01-20 18:04 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
>
> Doesn't that need to be
>
> (#s)(*[^\\]|)[^*?\(\)\<\>\{\}\|]*
>
> or something similar, so that a word beginning with "[[" can match?
> E.g. a word beginning with the pattern [[:alpha:].]
I did think about that. The documentation says "unless that suffix
itself contains characters eligible for expansion" so I thought I could
ignore trying to worry about an area that isn't the suffix. After
finding an example, I've concluded that it is better with your change.
The following shows the difference:
touch test/file
foo=file
: t*/$foo<tab>
: */$foo<tab>
The code doesn't only look in the suffix for "other characters eligible
for expansion" anyway. That'd be hard. Is it worth adjusting the
documentation?
There are still inconsistencies in the behaviour but people probably
don't have precise expectations if they ever try such things. Try this:
bar=test
: ./$bar/$foo<tab>
: ~/$bar/$foo<tab>
Oliver
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-01-20 18:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-16 22:22 Strange bug when completing [ in file names Tobias Gruetzmacher
2005-01-17 4:41 ` Bart Schaefer
2005-01-17 14:44 ` Tobias Gruetzmacher
2005-01-18 0:33 ` Bart Schaefer
2005-01-20 11:05 ` Oliver Kiddle
2005-01-20 15:29 ` Bart Schaefer
2005-01-20 18:04 ` Oliver Kiddle
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).