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

Re: tar completion fails on tar files with colon in names



Dear Daniel,

This change works for me.

Best,
Misha.

On Sat, 24 Dec 2022 at 12:17, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
Mikhail Gusarov wrote on Fri, Dec 23, 2022 at 13:17:26 +0100:
> However zsh completion for tar does not take it into account:
>
> % zsh -f
> % autoload -U compinit
> % compinit
> % tar --force-local -tf x:foo <TAB>tar: Cannot connect to x: resolve failed

The reproduction recipe requires ./x:foo to exist and be a valid tar
archive.

Can you try this?

diff --git a/Completion/Unix/Command/_tar b/Completion/Unix/Command/_tar
index f9901c0c9..1cabd9713 100644
--- a/Completion/Unix/Command/_tar
+++ b/Completion/Unix/Command/_tar
@@ -158,7 +158,7 @@ elif [[ ( "$_tar_cmd" = *[xt]* || -n $del ) && -n "$tf" ]]; then
   fi

   if [[ $tf != $_tar_cache_name && -f $tf ]]; then
-    _tar_cache_list=("${(@f)$($words[1] $largs $tf)}")
+    _tar_cache_list=("${(@f)$($words[1] ${words[(r)--force-local]} $largs $tf)}")
     _tar_cache_name=$tf
   fi


It doesn't account for possible quoting on the command line.

If it's right, might I ask for someone to commit/push this, please?
Trying not to stretch myself too thin.  Thanks.

Cheers,

Daniel


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