From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6431 invoked from network); 29 May 1998 19:03:35 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 29 May 1998 19:03:35 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id OAA22899; Fri, 29 May 1998 14:57:44 -0400 (EDT) Resent-Date: Fri, 29 May 1998 14:57:32 -0400 (EDT) From: "Bart Schaefer" Message-Id: <980529115541.ZM1633@candle.brasslantern.com> Date: Fri, 29 May 1998 11:55:41 -0700 In-Reply-To: <19980529161402.A12061@ens-lyon.fr> Comments: In reply to Vincent Lefevre "Re: completion ignoring" (May 29, 4:14pm) References: <199805221523.QAA17745@taos.demon.co.uk> <199805221534.LAA13850@luomat.peak.org> <980522095232.ZM29476@candle.brasslantern.com> <19980527142048.A20324@ens-lyon.fr> <19980527174141.G1747@math.fu-berlin.de> <19980529161402.A12061@ens-lyon.fr> In-Reply-To: Comments: In reply to Bruce Stephens "Re: completion ignoring" (May 29, 4:36pm) X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-users@math.gatech.edu Subject: Re: completion ignoring MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"4Z_Np2.0.Eb5.RKmRr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1562 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On May 29, 4:14pm, Vincent Lefevre wrote: } Subject: Re: completion ignoring } } On Wed, May 27, 1998 at 17:21:18 +0100, Bruce Stephens wrote: } > That's what I understood the question to be. And yes, isn't this how } > zsh works right now? } } No: } } $ benchmul[TAB] } benchmul-sparc4 benchmul-ultra1 benchmul.o } } (These 3 files are in a directory that is in my PATH.) } } -rw-r--r-- 1 vlefevre lip 1388 May 29 16:12 sparc/benchmul.o On May 29, 4:36pm, Bruce Stephens wrote: } Subject: Re: completion ignoring } } OK, I think that's a bug in 3.0.5 then. It's a deficiency (?) in building the command hash table, specifically. If you enter a full (or even relative) path to a prefix of the name of any non-executable file and then attempt to do command completion on it, it fails. But if you look at the output of "hash" you'll see that every file in every directory in $PATH has been put in the table -- and command completion reads the hash table by default, without further testing the file permissions on the target of the hashed name. gen_matches_files(), which is called for things not in the PATH, does do a stat() and look for the S_IEXEC bit. I don't think hashtable.c has changed much in 3.1.x, so this problem is likely still present. However, stat()-ing every file in every directory in $PATH is probably prohibitively slow, so this could reasonably only be handled as a special case during completion. Unfortunately, the code that determines whether a word matches the prefix is completely generic -- it doesn't know that the word came from the command hash table, or even that it's a command being completed -- and it works by adding the word to the completion list if it matches the prefix or by ignoring it if it doesn't match the prefix. There's no hook for discovering that the word *might* match and then doing an extra test on it using any other information (such as the target of the hash). So this behavior is unlikely to be changed anytime soon. Of course, you could do something like function xhash () { emulate -R zsh setopt localoptions local maybe cmd i=0 reply=() hash -f maybe=( $(hash -m ${1}\*${2}) ) for cmd in ${maybe##*\=} do ((++i)) [[ -x $cmd ]] && reply=( $reply ${${maybe[$i]}%\=*} ) done } compctl -C -aBF -K xhash -g '*(*)' This says, attempt to complete any aliases, builtins or functions, any executables in the hash table, and any executable files. The `xhash' function fills the hash table, lists everything in it that matches the prefix and suffix of the completion, then tests the path to which each hashes to see if it is executable before adding it to the result. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com