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

BUG: _canonical_paths wrongly escape tilde



Dear Zsh contributors,

I'm used to mount fs in my home directory (e.g. in ~/mnt).

When I try to unmount one of them by typing "umount ~/mn" and triggering completion, it gets completed to "umount \~/mnt", which the system does not understand.

I've tracked the completion : /usr/share/zsh/functions/Completion/Unix/_mount -> /usr/share/zsh/functions/Completion/Unix/_umountable -> /usr/share/zsh/functions/Completion/Unix/_canonical_paths.

It seems that:

  matches+=(${(q)${(M)files:#$canpref*}/$canpref/$origpref})

is the root cause and this Ai written patch help to confirm it:

 @@ -44,6 +44,13 @@
     # ### is ${"the word on the command line"/$origpref/$canpref}.
     # ### The following approximates that.
     matches+=(${(q)${(M)files:#$canpref*}/$canpref/$origpref})
+    # Do not escape a leading tilde in a user-entered path.
+    if [[ $origpref == '~'* ]]; then
+      local i
+      for (( i = 1; i <= $#matches; ++i )); do
+        [[ $matches[i] == '\~'* ]] && matches[i]=${matches[i]#\\}
+      done
+    fi
   fi

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

Sorry I couldn't write the patch myself, but this code still looks like black magic to me.
Hopefully, it can help.

Best regards,

Mathieu Maret




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