From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9206 invoked by alias); 23 Feb 2011 11:30:25 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28797 Received: (qmail 26528 invoked from network); 23 Feb 2011 11:30:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at ntlworld.com designates 81.103.221.47 as permitted sender) Date: Wed, 23 Feb 2011 11:30:04 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Cc: 353863@bugs.debian.org Subject: Re: Bugreport: completion hanging at ubo - endless loop Message-ID: <20110223113004.6e99ffa9@pws-pc.ntlworld.com> In-Reply-To: <2011-02-23T11-33-06@devnull.michael-prokop.at> References: <2011-02-23T11-33-06@devnull.michael-prokop.at> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.22.0; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=fUb5rNWQZtcA:10 a=kj9zAlcOel0A:10 a=xNf9USuDAAAA:8 a=NLZqzBF-AAAA:8 a=YkEX9gpMau50o0EcHR0A:9 a=LwSuEGzM1TbaHNx8wOoA:7 a=dMegQ1guPmwqVvNqX5qE6qvrEpUA:4 a=CjuIK1q_8ugA:10 a=_dQi-Dcv4p4A:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 On Wed, 23 Feb 2011 11:50:18 +0100 Michael Prokop 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 > > 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 Web page now at http://homepage.ntlworld.com/p.w.stephenson/