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

Re: Path with spaces in _canonical_paths



On Mon, Nov 21, 2022 at 2:49 AM <thomas@xxxxxxxxxx> wrote:
>
> The trace shows:
>
>         +_canonical_paths_add_paths:19> '(anon)'
>         [...]
>          +(anon):3> matches+=( '/tmp/My\ File' )
>
> but later:
>
>          +_canonical_paths_add_paths:28> matches+=( '/foo/My File' )

I still can't reproduce this, but given your trace output, try

diff --git a/Completion/Unix/Type/_canonical_paths
b/Completion/Unix/Type/_canonical_paths
index a8fbbb524..b2eff84df 100644
--- a/Completion/Unix/Type/_canonical_paths
+++ b/Completion/Unix/Type/_canonical_paths
@@ -42,7 +42,7 @@ _canonical_paths_add_paths () {
     # ### Ideally, this codepath would do what the 'if' above does,
     # ### but telling compadd to pretend the "word on the command line"
     # ### is ${"the word on the command line"/$origpref/$canpref}.
-    matches+=(${${(M)files:#$canpref*}/$canpref/$origpref})
+    matches+=( "${(@)${(@M)files:#$canpref*}/$canpref/$origpref}" )
   fi

   for subdir in $expref?*(@); do




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