From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 2F40124CEE for ; Sun, 14 Jul 2024 18:38:31 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1720975111; b=Eic6GkXHl9aOlraaGenjdH/IuKtm6i5/baq3Por3CXKqw/u2kd5+Wyplx5+ZLk3K/JtNYlhRlz jLjQpedK9nqjO1ORFRFJdK2dryCgv7aZwXDyr98HmnmRmOQ7bhn/1BRky1Kkdv5cNv/RUeZeAV 0PzY8kn+7cAW3YDcdJ/uOj1qM8rx4FdcBVhtnr2bGKFeDupq80yPgNGlnoqunqEWmEpnEmZPtd gc+MzpE0z+zHi1gtQr7MjB0hzfGtzE2BC4yO4SnU64zB+easOwNgN6Q26u8Z+PmgB7g/hvx5/c wX4rWGQD3cr+73I41ES3w83yMlq26jUITiVKjb5M51MNVA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mout.gmx.net) smtp.remote-ip=212.227.15.18; dkim=pass header.d=gmx.com header.i=llua@gmx.com header.s=s31663417 header.a=rsa-sha256; dmarc=pass header.from=gmx.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1720975111; bh=s6t44ngX5g/ETonl4kD6xu1/PWJ7D46GDqEFmSGYnCI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature: DKIM-Signature; b=GOscEvXuYPFnY55yHnsRkNNjXJrFnvmg/0eXNk2ejmh5GRPolnwAeXyOEcEjWcQslfV1AGQjiQ EKQBH7KzfqXJaXJymckpFSiw7zhOnpetwne2CVW4Enr7jJAnDfRwCET69Eo+wdWXhdjKOBUfMG 6ZRHoBAeDdg3XhHRd7tDGbRFBw7PfoBMyyN1tFg56SiFyyysakrIRFVfnhcI3KYhuvls/HL1g9 5tAPdBlG7E+eKSR1y3pk9gp1LyiIPxlcrt9F4H4zlAtOEuxWGAkZgj8WBmkAq+x4zF0S/k7rsA Xf3mmmGIt/GTUu5AoOP9F5/lSbpg06PdThyhVtPw2cgWSg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ov7xCWFYiR2gRGEaESLdCElLaSWtac9YC2j5o4tvYK4=; b=EHQTeAZWsBwvgwkgttK04pGOTS n+KEFS+j2tYC2Z5MrOw7FvGyhalMOWCKFs23QIdfKJ9iOvpt6QiOjIMKvi1KFYs/AWV14vxF++eXE 1GJRwjxLvlSuBrJBST6M3mQlWxkJTKMGMdlMuvXC/lK06w8s+fLf1Zi8zwScAeBjSHd6TYAQpnpjc AH3tsPwk9dMfxCtXKqY8vrt2gE8hrJ9+3979epeEw6xVx0hMLYKe5sa2zA4vV7VuNYKA/Nyev1KSL S5fcEsfiKt/dPwJFuw1XUmyXgIN35O1+ipqZ+dbf5OGKYx25RcaQi7DQP1s5CYJH5dp1YnJQTzpsJ V1iLZZPQ==; Received: by zero.zsh.org with local id 1sT2F3-000BO0-VP; Sun, 14 Jul 2024 16:38:30 +0000 Authentication-Results: zsh.org; iprev=pass (mout.gmx.net) smtp.remote-ip=212.227.15.18; dkim=pass header.d=gmx.com header.i=llua@gmx.com header.s=s31663417 header.a=rsa-sha256; dmarc=pass header.from=gmx.com; arc=none Received: from mout.gmx.net ([212.227.15.18]:37297) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1sT2EE-000B4a-6j; Sun, 14 Jul 2024 16:37:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.com; s=s31663417; t=1720975057; x=1721579857; i=llua@gmx.com; bh=ov7xCWFYiR2gRGEaESLdCElLaSWtac9YC2j5o4tvYK4=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=LFdbaHcP+NtEIabhSYGaxy1Ty2ZBsbjKQ/8FcGBVC7CHoVmgmSkAgJOnSNssjrhU 6gaFbj6crkE2QU33UCgRkEXhlSQo2X10BB5uSuuA3hC/9r+IJLiYjbe/uQpBAUAnf ehh0Tsd9G5sPm17YufXKjGR9c0ml0jdcRhWg+gvPDg6JlpJ6eeNG5ry13ND+WBmV/ X+4v8s5Nd4kgj1UKKCAd4g67LK4ankOcmfakuIMk61HCpd0Fr0f3GD6EDH9dKNqq1 LO4IdkgwN23ZxSwYveNP+pgS3qaaQD7JSrHs+bFMZqVMydEjXDg9picIY0Lqj8hvw LntEXzOZLJwYOj0ndA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [10.0.0.14] ([67.177.154.237]) by mail.gmx.net (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1Mxm3Q-1s9XyD2psE-00rDOa for ; Sun, 14 Jul 2024 18:37:37 +0200 Message-ID: Date: Sun, 14 Jul 2024 12:37:33 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] remote files completion: remove double-escaping To: zsh-workers@zsh.org References: <863E0019-2AFF-4CD2-AF2B-A80499908D95@zsh.org> Content-Language: en-US From: Eric Cook In-Reply-To: <863E0019-2AFF-4CD2-AF2B-A80499908D95@zsh.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:9Fn0e0po9X0rp/jtSdhgo5vOPSByv/g6NdQCa773VUF9kHN7lgx vFSVDYPf7fic79Xd37/xMJ+T6nvP8Iu1imffWqMbHwFUE3yiez0Q7uNtk6z8azfTQhQXR+H UNJgz4KiRTecisCGIbp1/48GdifuqCkGS8FdT6zEcNF2P8vioGMh6Qywn8dHp8sX/GdBVHY MnJxkjjlcWEs4LVVVeKZw== UI-OutboundReport: notjunk:1;M01:P0:AnFZHeRUIo0=;bmRFjvekoiNf3DcSJ8VV9auTF7H BRXw7s9mD/zpMhU7KjbN7vzJ8njhm0nMN5p9xPQr59UJvJ/PbmApKS++i2lWX9iJF/ZFXZXUx 8adYrJ0xGKkISyEnUja0aSeP9Ic37Xzb/tQl2n9GbfMN33ci/lkrs9xTjfHkjMn0lcM+VNZut 6qFzxs9EPSqhPvEDyIT7kRYS8zLrXcM8W6hD5h7q7fSDKd9R/st6HiJTItZFulFDS7VhW66LU +LbCWG8RMGuOVjvCjfwD/27U2ScovNvxV96E5L11ERGcwpiUt9mAZwpbaPoFpq3/GkeYHhup7 ADEU/lWHBwnSd9Mi4GjOvZEDecWKWsIkM709MRKWd1XLU/1gKTbBMPAJ3LdER+8vJkKpRz+bB KIQ1z4uNeNxRAUr0nXVVI31wRAaHL//OcamGB8T1B19LbaPqS2iCqOfEVUQVdIP04SV/ZxSBc yXv1Kk1VI/YqJUBHrIfdT8y77JbfA6Q3ith7+KpXrOqO2TJRpiexfzC6d2MhAdb9Efq2wdNTa dY4CsbYAblUoa8oGdemIh9r3ZK761reVCTEIRvgpphkQrT8O5FwyznArTg8DvEv/CmmPRfhkn 1oRWvaINn90EVTNRhK2mhJetENxiSyth8PGEMeY/BAy5So8eidEfwCWacJAahX43XS2PfOfgW KXuCM7vPN8a3I311JKbJpJ2OnTOmnVQp9MHUBU8EhISNht02kkcmr4m53Svi4hgJYQbD7tYnA pvBvFQ9AQmYsSxjdX3EGeAc91kUV5RfM+0BvMOwqvgQypKORpNgwzMrBt/Xt0RjS72iPgw5+d oAeuIkUUbFOL+WyQ2SzEq1MQ== X-Seq: 52989 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On 7/8/24 5:17 PM, Lawrence Vel=C3=A1zquez wrote: >> On May 28, 2024, at 11:40 AM, Lyn Fugmann wrote: >> >> I finally got around to testing this. The behavior appears to depend on= ly on the local version of rsync, not on the remote version. Tested using = local rsync 3.2.3 and 3.2.7, remote rsync 3.1.3 and 3.2.7. So I think the = patch should be fine as is. (I would expect very few people to run an over= two years old version of rsync and a recent version of zsh on the same lo= cal machine.) > > A GitHub user is inquiring about the status of this contribution. > > https://github.com/zsh-users/zsh/pull/114#issuecomment-2212591419 > a possible fix, open to a better option letter for _remote_files than -Q, = since compadd has -Q. diff --git a/Completion/Unix/Command/_rsync b/Completion/Unix/Command/_rsy= nc index c65266dbd..81d25a3f4 100644 =2D-- a/Completion/Unix/Command/_rsync +++ b/Completion/Unix/Command/_rsync @@ -60,7 +60,14 @@ elif compset -P 1 '*::' || compset -P 1 'rsync://*/'; t= hen elif compset -P 'rsync://'; then _rsync_user_or_host / "$@" elif compset -P 1 '*:'; then - _remote_files -- ssh + if [[ -v opt_args[(i)client---old-args] || $RSYNC_OLD_ARGS =3D 1 ]]; th= en + _remote_files -- ssh + else + # the 3.2.4+ way that rsync handles filenames does not protect *, ? a= nd [] + # so those characters still need to be escaped to prevent being treat= ed as + # a pattern in the remote shell. + _remote_files -Q '[][*?]' -- ssh + fi else _rsync_user_or_host : "$@" fi @@ -236,6 +243,7 @@ _rsync() { '*--include=3D[do not exclude files matching pattern]:pattern' \ '--files-from=3D[read list of source-file names from specified file]= :file:_files' \ '(-0 --from0)'{-0,--from0}'[all *-from file lists are delimited by n= ulls]' \ + '--old-args[disable the modern arg-protection idiom]' \ '(-s --secluded-args)'{-s,--secluded-args}'[use the protocol to safe= ly send arguments]' \ "--trust-sender[trust the remote sender's file list]" \ '--copy-as=3D[specify user & optional group for the copy]:user:_rsyn= c_users_groups' \ diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_re= mote_files index 93e1b7f43..3f5459aad 100644 =2D-- a/Completion/Unix/Type/_remote_files +++ b/Completion/Unix/Type/_remote_files @@ -11,6 +11,7 @@ # - -g: specify a pattern to match against files # p, =3D and * glob qualifiers supported # - -h: specify the remote host, default is ${IPREFIX%:} +# - -Q: specify a pattern of characters to escape in the returned filenam= es # - -W: specify the parent directory to list files from, # default is the home directory # @@ -31,14 +32,14 @@ # There should be coloring based on all the different ls -F classifiers. -local expl rempat remfiles remdispf remdispd args cmd suf ret=3D1 +local expl rempat remfiles remdispf{,q} remdispd{,q} args cmd suf ret=3D1 local -a args cmd_args -local glob host dir dirprefix +local glob host dir esc dirprefix if zstyle -T ":completion:${curcontext}:files" remote-access; then # Parse options to _remote_files. Stops at the first "--". - zparseopts -D -E -a args / g:=3Dglob h:=3Dhost W:=3Ddir + zparseopts -D -E -a args / g:=3Dglob h:=3Dhost W:=3Ddir Q:=3Desc (( $#host)) && shift host || host=3D"${IPREFIX%:}" args=3D( ${argv[1,(i)--]} ) @@ -85,6 +86,14 @@ if zstyle -T ":completion:${curcontext}:files" remote-a= ccess; then remdispf=3D( ${(M)remdispf:#${~glob[2]}} ) fi + if (( $#esc )); then + remdispfq=3D(${${remdispf%[*=3D|]}//(#b)(${~esc[2]})/\\$match[1]}) + remdispdq=3D(${${remdispd%/}//(#b)(${~esc[2]})/\\$match[1]}) + else + remdispfq=3D(${(q)remdispf%[*=3D|]}) + remdispdq=3D(${(q)remdispd%/}) + fi + local -a autoremove [[ -o autoremoveslash ]] && autoremove=3D(-r "/ \t\n\-") @@ -92,9 +101,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-a= ccess; then while _tags; do while _next_label remote-files expl ${suf:-remote directory}; do [[ -n $suf ]] && - compadd "$args[@]" "$expl[@]" -d remdispf -- ${(q)remdispf%[*= =3D|]} && ret=3D0 + compadd "$args[@]" "$expl[@]" -d remdispf -- $remdispfq && ret=3D= 0 compadd ${suf:+-S/} $autoremove "$args[@]" "$expl[@]" -d remdispd = \ - -- ${(q)remdispd%/} && ret=3D0 + -- $remdispdq && ret=3D0 done (( ret )) || return 0 done