From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id SAA08516 for ; Fri, 13 Sep 1996 18:02:20 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id DAA27318; Fri, 13 Sep 1996 03:52:32 -0400 (EDT) Resent-Date: Fri, 13 Sep 1996 03:52:32 -0400 (EDT) Message-Id: <199609130750.JAA06341@hydra.ifh.de> X-Authentication-Warning: hydra.ifh.de: Host pws@localhost didn't use HELO protocol To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Re: [zash-3.0.0] bug in cdmatch for dirs w/ embedded space? In-reply-to: ""alain (a.) caron""'s message of "Thu, 12 Sep 1996 15:38:00 MET." <"9653 Thu Sep 12 18:01:31 1996"@bnr.ca> Date: Fri, 13 Sep 1996 09:50:49 +0200 From: Peter Stephenson Resent-Message-ID: <"VeCVv.0.jg6.0BHEo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2138 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu "alain (a.) caron" wrote: > >reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t:gs/ /\\\\ /) ) > > replace this last line by: > > reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t) ) Yes, this works. However, this version of cdmatch has the (for me at least) critical limitation that it doesn't handle subdirectories, just the first one below the directory in $cdpath. I've gone back to a previous version of cdmatch and applied the same treatment, which works there too, so the following is what I'm using at the moment. Sorry, I can't remember who wrote this one originally. The compctl instructions at the top of the other one still apply, though I find it simpler to see if ordinary completion will find a directory, and only then use cdmatch: compctl -g '*(-/)' + -K cdmatch -S / -q cd pushd ############################################################################### # cdmatch - directory matching for cd # # Save in your functions directory and autoload, then do # compctl -K cdmatch -S / -q + -g '*(D-/)' cd pushd # # Completes directories using cdpath (as cd does). . is automatically # included, because cd works that way. # # If an absolute path is being specified, or cdpath is blank, the completion is # left up to the shell. This results in such completions having a different # look from those done by cdmatch itself. Hopefully a future version of zsh # will rectify this in some way. local notonlydot npos args pref dir d reply=() # check for cdpath empty or only containing . for dir in $cdpath; do [[ $dir != . ]] && notonlydot=1; done if [[ $notonlydot != 1 ]]; then return; fi # get word on which completion is requested read -nc npos read -Ac args # check for absolute path - watch out for erroneous ~ expansion pref=x$args[$npos] if [[ $pref[2] = [/\~] ]]; then return; fi # relative path - use cdpath pref=$args[$npos] for dir in . $cdpath; do for d in $dir/$pref*(ND-/:s,$dir/,,); do reply=( $reply ${d%%/#} ) done done return ############################################################################### -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330 Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.