Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH _cd: completion fails for "cd .." if $PWD/.. contains a space



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



Messages sorted by: Reverse Date, Date, Thread, Author