From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3738 invoked by alias); 28 Dec 2013 08:00:34 -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: 32190 Received: (qmail 5060 invoked from network); 28 Dec 2013 08:00:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) 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.2 From: Bart Schaefer Message-id: <131228000041.ZM25439@torch.brasslantern.com> Date: Sat, 28 Dec 2013 00:00:41 -0800 In-reply-to: <8C206EB3503E4B9FAF437799DFF051CD@fueledbylemons.com> Comments: In reply to Alexey Bezhan "PATCH _cd: completion fails for "cd .." if $PWD/.. contains a space" (Dec 27, 9:15pm) References: <8DAABB32CF84427596279B599BB929DB@fueledbylemons.com> <8C206EB3503E4B9FAF437799DFF051CD@fueledbylemons.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: PATCH _cd: completion fails for "cd .." if $PWD/.. contains a space MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 27, 9:15pm, Alexey Bezhan wrote: } } There's a bug in _cd completion that results in empty result when trying to } complete after "cd ../" if there's a space somewhere in $PWD/.. } } The following patch fixes the space issue, but there may be other cases that } cause the same behavior that aren't fixed by this change. } } - tmpWpath=(-W $tmpprefix) } + tmpWpath=(-W \"$tmpprefix\") Thanks ... your patch seems to have been slightly mangled in transit. After looking at this for a while I think you are close, but not quite right. There are two uses of $tmpWpath, but I believe only one of them needs additional quoting. This also needs to be careful to quote each element of the array before the elements are joined, because the reference is inside double-quotes. diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd index a5d328f..b9860ff 100644 --- a/Completion/Zsh/Command/_cd +++ b/Completion/Zsh/Command/_cd @@ -100,7 +100,7 @@ else # already handled by _command_names (see _autocd) [[ CURRENT -ne 1 || ( -z "$path[(r).]" && $PREFIX != */* ) ]] && - alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files $tmpWpath -/" "$alt[@]" ) + alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files ${(j: :)${(@q)tmpWpath}} -/" "$alt[@]" ) if [[ CURRENT -eq argstart && noopts -eq 0 && $PREFIX = -* ]] && zstyle -t ":completion:${curcontext}:options" complete-options; then