Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bugreport: completion hanging at ubo<Tab> - endless loop



On Wed, 23 Feb 2011 11:50:18 +0100
Michael Prokop <news@xxxxxxxxxxxxxxxxx> wrote:
> in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=353863
> Sebastien Desreux reported a bug about zsh with its
> completion system in a specific situation.
> 
> To trigger the bug (at least 4.3.10 and 4.3.11 in Debian are
> known to be affected by this bug):
> 
>   zsh -f
>   autoload -Uz compinit; compinit; alias ubox=ls
>   ubo<tab>
> 
> Then the zsh process is hanging in an endless loop, eating CPU.

Tee hee.  This is what happens when your interface between the
completion system and the main shell is a complete hack.

If the option COMPLETE_ALIASES is off, the shell tries to expand
aliases, so it can do completion for aliased commands without the
completion system needing to understand the alias.

To analyse a command line to find the current context, completion adds
an "x" at the cursor position which it later removes.  In this case, the
"x" completes the word "ubox", which is then expanded to "ls".  The
completion system doesn't notice and assumes it still has the original
command line.  It removes the non-existent "x" to get "l" which it
thinks is three characters long.  It then loops for ever reading the
null byte at the end of the string waiting to get to the third
character.

I think the answer might be never to expand aliases when the "x" would
be added to the command word.  That might be easier said than done.

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author