zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] remote files completion: remove double-escaping
@ 2024-04-10 10:46 Lyn Fugmann
  2024-04-10 18:45 ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Lyn Fugmann @ 2024-04-10 10:46 UTC (permalink / raw)
  To: zsh-workers

Removes the double escaping in the remote files completion. This affects rsync and scp.
For example, instead of a space character in a remote filename turning into `\\\ `, it will now correctly turn into `\ `.
While scp apparently works with either one, rsync requires the latter since version 3.2.4[1] (unless the legacy behavior is explicitly enabled).
This has been a problem for almost two years now.

[1]: https://download.samba.org/pub/rsync/NEWS#3.2.4


diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files
index 93e1b7f43..4d4a7abbf 100644
--- a/Completion/Unix/Type/_remote_files
+++ b/Completion/Unix/Type/_remote_files
@@ -60,10 +60,7 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
     dirprefix=${dir}/
   fi
 
-  if [[ -z $QIPREFIX ]]
-    then rempat="${dirprefix}${PREFIX%%[^./][^/]#}\*"
-    else rempat="${dirprefix}${(q)PREFIX%%[^./][^/]#}\*"
-  fi
+  rempat="${dirprefix}${(q)PREFIX%%[^./][^/]#}\*"
 
   # remote filenames
   remfiles=(${(M)${(f)"$(
@@ -92,9 +89,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
   while _tags; do
     while _next_label remote-files expl ${suf:-remote directory}; do
       [[ -n $suf ]] &&
-          compadd "$args[@]" "$expl[@]" -d remdispf -- ${(q)remdispf%[*=|]} && ret=0
+          compadd "$args[@]" "$expl[@]" -d remdispf -- ${remdispf%[*=|]} && ret=0
       compadd ${suf:+-S/} $autoremove "$args[@]" "$expl[@]" -d remdispd \
-	-- ${(q)remdispd%/} && ret=0
+	-- ${remdispd%/} && ret=0
     done
     (( ret )) || return 0
   done


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

* Re: [PATCH] remote files completion: remove double-escaping
  2024-04-10 10:46 [PATCH] remote files completion: remove double-escaping Lyn Fugmann
@ 2024-04-10 18:45 ` Mikael Magnusson
  2024-04-12 18:59   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2024-04-10 18:45 UTC (permalink / raw)
  To: Lyn Fugmann; +Cc: zsh-workers

On Wed, Apr 10, 2024 at 12:47 PM Lyn Fugmann <me@fugi.dev> wrote:
>
> Removes the double escaping in the remote files completion. This affects rsync and scp.
> For example, instead of a space character in a remote filename turning into `\\\ `, it will now correctly turn into `\ `.
> While scp apparently works with either one, rsync requires the latter since version 3.2.4[1] (unless the legacy behavior is explicitly enabled).
> This has been a problem for almost two years now.

This should probably be behind a zstyle (I guess it's fine if it
defaults to the new behavior), as currently this patch will break
completion for older versions of scp and rsync. That way users can
easily configure it per command or globally if they want.

> diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files
> index 93e1b7f43..4d4a7abbf 100644
> --- a/Completion/Unix/Type/_remote_files
> +++ b/Completion/Unix/Type/_remote_files
> @@ -60,10 +60,7 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
>      dirprefix=${dir}/
>    fi
>
> -  if [[ -z $QIPREFIX ]]
> -    then rempat="${dirprefix}${PREFIX%%[^./][^/]#}\*"
> -    else rempat="${dirprefix}${(q)PREFIX%%[^./][^/]#}\*"
> -  fi
> +  rempat="${dirprefix}${(q)PREFIX%%[^./][^/]#}\*"
>
>    # remote filenames
>    remfiles=(${(M)${(f)"$(
> @@ -92,9 +89,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
>    while _tags; do
>      while _next_label remote-files expl ${suf:-remote directory}; do
>        [[ -n $suf ]] &&
> -          compadd "$args[@]" "$expl[@]" -d remdispf -- ${(q)remdispf%[*=|]} && ret=0
> +          compadd "$args[@]" "$expl[@]" -d remdispf -- ${remdispf%[*=|]} && ret=0
>        compadd ${suf:+-S/} $autoremove "$args[@]" "$expl[@]" -d remdispd \
> -       -- ${(q)remdispd%/} && ret=0
> +       -- ${remdispd%/} && ret=0
>      done
>      (( ret )) || return 0
>    done

-- 
Mikael Magnusson


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

* Re: [PATCH] remote files completion: remove double-escaping
  2024-04-10 18:45 ` Mikael Magnusson
@ 2024-04-12 18:59   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2024-04-12 18:59 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Lyn Fugmann, zsh-workers

On Wed, Apr 10, 2024 at 11:45 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> On Wed, Apr 10, 2024 at 12:47 PM Lyn Fugmann <me@fugi.dev> wrote:
> >
> > Removes the double escaping in the remote files completion. This affects rsync and scp.
> > For example, instead of a space character in a remote filename turning into `\\\ `, it will now correctly turn into `\ `.
> > While scp apparently works with either one, rsync requires the latter since version 3.2.4[1] (unless the legacy behavior is explicitly enabled).
> > This has been a problem for almost two years now.
>
> This should probably be behind a zstyle (I guess it's fine if it
> defaults to the new behavior), as currently this patch will break
> completion for older versions of scp and rsync. That way users can
> easily configure it per command or globally if they want.

Doesn't this actually depend on the remote version rather than the
local command?  Might need to be configurable based on the
destination?

See also thread starting with workers/50484 from 2022 Subject: rsync completions


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

end of thread, other threads:[~2024-04-12 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-10 10:46 [PATCH] remote files completion: remove double-escaping Lyn Fugmann
2024-04-10 18:45 ` Mikael Magnusson
2024-04-12 18:59   ` Bart Schaefer

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).