zsh-workers
 help / color / mirror / code / Atom feed
* tar completion fails on tar files with colon in names
@ 2022-12-23 12:17 Mikhail Gusarov
  2022-12-24 11:17 ` Daniel Shahaf
  0 siblings, 1 reply; 4+ messages in thread
From: Mikhail Gusarov @ 2022-12-23 12:17 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

Hello.

GNU tar has a "feature" where it treats tar filenames with colons in it as
files on remote filesystems:

% tar tf x:foo
tar: Cannot connect to x: resolve failed
%

It has an option to disable this "helpful" behaviour:

% tar --force-local -tf x:foo
xx
%

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

Best,
Misha.

[-- Attachment #2: Type: text/html, Size: 750 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: tar completion fails on tar files with colon in names
  2022-12-23 12:17 tar completion fails on tar files with colon in names Mikhail Gusarov
@ 2022-12-24 11:17 ` Daniel Shahaf
  2022-12-24 14:44   ` Mikhail Gusarov
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Shahaf @ 2022-12-24 11:17 UTC (permalink / raw)
  To: Mikhail Gusarov; +Cc: zsh-workers

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: tar completion fails on tar files with colon in names
  2022-12-24 11:17 ` Daniel Shahaf
@ 2022-12-24 14:44   ` Mikhail Gusarov
  2022-12-30 20:50     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Mikhail Gusarov @ 2022-12-24 14:44 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1243 bytes --]

Dear Daniel,

This change works for me.

Best,
Misha.

On Sat, 24 Dec 2022 at 12:17, Daniel Shahaf <d.s@daniel.shahaf.name> 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
>

[-- Attachment #2: Type: text/html, Size: 1811 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: tar completion fails on tar files with colon in names
  2022-12-24 14:44   ` Mikhail Gusarov
@ 2022-12-30 20:50     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2022-12-30 20:50 UTC (permalink / raw)
  To: zsh-workers

On Sat, 2022-12-24 at 15:44 +0100, Mikhail Gusarov wrote:
> Dear Daniel,
> 
> This change works for me.
> 
> Best,
> Misha.
> 
> On Sat, 24 Dec 2022 at 12:17, Daniel Shahaf <d.s@daniel.shahaf.name> 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?
> > 

I've committed this.

pws



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-30 20:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 12:17 tar completion fails on tar files with colon in names Mikhail Gusarov
2022-12-24 11:17 ` Daniel Shahaf
2022-12-24 14:44   ` Mikhail Gusarov
2022-12-30 20:50     ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).