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 DAA07206 for ; Fri, 13 Sep 1996 03:52:05 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id NAA17632; Thu, 12 Sep 1996 13:44:10 -0400 (EDT) Resent-Date: Thu, 12 Sep 1996 13:44:10 -0400 (EDT) Date: Thu, 12 Sep 1996 11:42:29 -0600 Message-Id: <199609121742.LAA14407@charney.cdc.noaa.gov> From: Mark Borges To: ZSH mailing list Subject: [zash-3.0.0] bug in cdmatch for dirs w/ embedded space? Organization: CIRES, University of Colorado X-Attribution: mb Resent-Message-ID: <"PxXKg.0.QJ4.fl4Eo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2133 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu I'm trying to get zsh to complete a directory that has an embedded space, e.g., `foo bar' (personally I don't like them, but with mac/win95 filenames it seems to be pretty common to come across). I used the versions of compctl, cdmatch, and cdmatch2 distributed with zsh-3.0.0, and invoked zsh with the -f switch. It fails because too many backslashes get put in the completion, e.g., % cd foo results in % cd foo\\\ bar/ Is there a more up to date cdmatch/compctl for this sort of thing? Or is there a (non-default) that needs to be set? Thanks. Here's exactly what I did: charney$ ~/bin/sunos-5.5/zsh-3.0.0 -f charney% echo $ZSH_VERSION 3.0.0 charney% ls foo bar charney% if [[ -o AUTO_REMOVE_SLASH ]] then then> compctl -x 'p[2]' -Q -K cdmatch2 - 'S[/][~][./][../]' -g '*(-/)' + \ then> -g '*(-/D)' - 'n[-1,/], s[]' -K cdmatch -q -S '/' -- cd pushd then> else else> compctl -x 'p[2]' -Q -K cdmatch2 - 'S[/][~][./][../]' -g '*(-/)' + \ else> -g '*(-/D)' - 'n[-1,/], s[]' -K cdmatch -S '/' -- cd pushd else> fi charney% fpath=(~/.zfunctions) charney% autoload cdmatch charney% autoload cdmatch2 charney% cd foo\\\ bar/ # typed cd foo here cd: no such file or directory: foo\ bar/ charney% cd foo\ bar charney% pwd /tmp/mdb/foo bar charney% cat ~/.zfunctions/cdmatch # Start of cdmatch. # Save in your functions directory and autoload, then do # compctl -x 'S[/][~][./][../]' -g '*(-/)' - \ # 'n[-1,/], s[]' -K cdmatch -S '/' -- cd pushd # # Completes directories for cd, pushd, ... anything which knows about cdpath. # You do not have to include `.' in your cdpath. # # It works properly only if $ZSH_VERSION > 2.6-beta2. For erarlier versions # it still works if RC_EXPAND_PARAM is not set or when cdpath is empty. local narg pref cdp read -nc narg read -Ac pref cdp=(. $cdpath) reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t:gs/ /\\\\ /) ) return # End of cdmatch. charney% cat ~/.zfunctions/cdmatch2 # This function should be called from compctl to complete the # second argument of cd and pushd. local from read -Ac from from="${from[2]}" eval "reply=( \${PWD:s@$from@$1*$2@}~$PWD(ND-/:) )" reply=( "${${reply[@]#${PWD%%$from*}}%${PWD#*$from}}" ) [[ ${#reply[(r),-1]} != 0 ]] && reply[(r)]="''" return charney% charney$ -- -mb-