From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23387 invoked from network); 23 Nov 2022 22:25:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Nov 2022 22:25:46 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1669242347; b=fQ9S8570VDitB/cqXOvVTkXsxwtF/Q+7msgjOosLuU8jTRB4WLa3R0/WPK4Vv2gplt8iwtyFh/ lzfieae72KBnEnWKzfbd1rOzSKxJ/AkjrvaUHCROgRcCojujlWTsGwaOWbiWibgz9eU5mhBLsf Wl9M5BLlnGk1I8mfRdrVQ6I6f1w7hoQP18bW4JcNCae4KkFr6jePS9PsOuvzZkuP5uSLb3hjJe 9pzXdAU6tr2jAKxIo1tnHTQlrkKS5GpE/KtgQqp4J37MMUphrkxnlWXasvQMU1d+k6KIb2Ayg8 Dr6yWz4zK/pz+TpDW7Y7huhA5vxsQ43a/5J9D65zwg2rnQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1669242347; bh=QFFI49jFy+sEcoTGnNCUY4gpscBkeRtS2oxVo+FA2M8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:Cc:To:From: Date:References:In-Reply-To:Message-ID:MIME-Version:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=fyAdwistc+Fhc2MV7JXDVDko3JYfmarlZw6gPjBVq//vLE7HMeKzy5DL+XN2v/l4bWtUtclzCS 7vcfhrqH0zbWyGPzcq4yEs14IFWBEZmwn0gPfBLPGclQ7updy0KpJvD1MyUuPet9m3CWeP84dx 3/7FVn3UDE2fMf8vJ/XNRMS4+JEz0DKfs+gX5/Nw2VGQhWTD7T8tgODRXgbOo1Jg0jsLCpmboE y7YHNWasQONylsPzDA5VI2DPDKvtMKv+KKX+UU5YM74x22SqKt6s720vQZ3MJRSX0EH6cT1O4O xNUMfy7v4UUzgNSjfLxreuNoYBWV8xDE994nb9FhmKYi7w==; 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:Subject:Cc:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=0EMsiSlWQ2+0T4fjkSSDcAJ6itF4WD/FexeIKXlLZQA=; b=fWRJ8ZpNGiivrEDvXqcnK8DH/e rbRbn4r2UeIRnyLvQGn8R2P3kxQxUszog8B0wiDvBw40FsxasRKNk9OTQy8RDTiakLI5OH8zu9eKT G9M/5A+enzXVMDJaAx8G+5AyXVKGQEPjG/9L8xp3EIOTtfzxvaEo89AyCi1NAfgPB7eaHEZCk82no 1m2yDaQ4gg+vuRYZVK7c7Yh2Ur9zIBXtENBiigdz34gaCuB0+PQb5gGr9u/+Worr07Cm/0UzKxUWr cS3GPnmyi0DMnbJQAfAQc49BkAAuujHHlQVdKC5Wjw1l0NPWaXRaH+siv8bWbPzlEAIWuJcCWOBlh e16gG0IA==; Received: by zero.zsh.org with local id 1oxyBd-0004CD-SN; Wed, 23 Nov 2022 22:25:46 +0000 Authentication-Results: zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out4-smtp.messagingengine.com ([66.111.4.28]:49915) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oxyAt-0003sP-Pc; Wed, 23 Nov 2022 22:25:01 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 531125C00E4; Wed, 23 Nov 2022 17:24:58 -0500 (EST) Received: from imap46 ([10.202.2.96]) by compute2.internal (MEProxy); Wed, 23 Nov 2022 17:24:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1669242298; x=1669328698; bh=0EMsiSlWQ2 +0T4fjkSSDcAJ6itF4WD/FexeIKXlLZQA=; b=E+/ptkxiLqjVkUttA3zgAesddy zWuuRUiOKwxCi+HBnVcP5Vc/RBlgQIABPdIuywVzleTyPVZQ5LWCw+z2bM/hNROv 35AJ8+x52k+kw/MVugOWjlVHeVew+EzbxddiAw0TvZj/c1SMBuxWoyjlHgaX1aw4 k8+1sPM8jw4VaVWNscJUFDVQx8PEwubXJjB+Js/eZG4Y4egVYCoJ2/Gg8wSBkOWI g/oTREIlbQG467YxCrdqCENTsfOsU/YeMX4ppuUTx5dHji64ztb36gJsFiPbw/Cl cq+zLvLU5c4RfSs20cdOPOPsHlnRFOrVisNtA3hfY7yjTtBStbX2fzMMK4Aw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1669242298; x= 1669328698; bh=0EMsiSlWQ2+0T4fjkSSDcAJ6itF4WD/FexeIKXlLZQA=; b=u yPH5O70zFl5bYmfhC9qDw1W4ohrRpSp+KE96Y5ODTU13EttJnF9OHXWqwSKZiwrx 58jCXTTAAKTfCrDFMkphzSJvySXVxg/MJ9XH4/G/h29xsyHWztkD9onS0RmbcOL+ P8ub6h2MmztLRc6G81JZxtgEtLRcv/UrXsjjfD3mx7JrTDCy6asaCT9E1tEF9YxX UvooJI976kEgKHN7lfgiMXaHlC6h71UbXs9e4UfyHmIWYMk4vyr2jSsSCl/K7RZt jeDrrprN7Ty8hi8xOAoFFj2BhEBe+ZxLS1YJYMZ+tAfqQQpQI2zzHqkVwB6ML4Pf KO7z1OWLnfVXAMlgQDwlg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedriedugdduheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdff rghnihgvlhcuufhhrghhrghffdcuoegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrg hmvgeqnecuggftrfgrthhtvghrnhepffdvheeutddugeejledtjeethfehueeukeeijeeh ueduiefgfeevjeeiieeifedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i425e4195:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A71DA2A20080; Wed, 23 Nov 2022 17:24:57 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1115-g8b801eadce-fm-20221102.001-g8b801ead Mime-Version: 1.0 Message-Id: In-Reply-To: References: <45820bd7-fab6-70f5-5abb-dc444f6f1075@coldfix.de> <20221123141357.GL27622@tarpaulin.shahaf.local2> Date: Wed, 23 Nov 2022 22:24:35 +0000 From: "Daniel Shahaf" To: "Bart Schaefer" Cc: zsh-workers@zsh.org, =?UTF-8?Q?Thomas_Gl=C3=A4=C3=9Fle?= Subject: Re: Path with spaces in _canonical_paths Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 51046 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: Bart Schaefer wrote on Wed, 23 Nov 2022 21:36 +00:00: > On Wed, Nov 23, 2022 at 6:14 AM Daniel Shahaf = wrote: >> >> Bart Schaefer wrote on Mon, Nov 21, 2022 at 13:32:41 -0800: >> > On Mon, Nov 21, 2022 at 9:41 AM Thomas Gl=C3=A4=C3=9Fle wrote: >> > > >> > > + local -a tmp_buffer >> > > + compadd -A tmp_buffer "$__gopts[@]" -a files >> > > [...] >> > > + matches+=3D( "${(@)tmp_buffer/$canpref/$origpref}" ) >> > > else >> > > # ### Ideally, this codepath would do what the 'if' above d= oes, >> > > # ### but telling compadd to pretend the "word on the comma= nd line" >> > > # ### is ${"the word on the command line"/$origpref/$canpre= f}. >> > > - matches+=3D(${${(M)files:#$canpref*}/$canpref/$origpref}) >> > > + matches+=3D(${${(M)tmp_buffer:#$canpref*}/$canpref/$origpref= }) >> > > fi >> >> The comment quoted above concerns how the candidate completions are >> compared to the word on the command line. The comment says that, >> instead of applying s/foo/bar/ to the word on the command line and >> comparing the result against the raw candidate completions, the rever= se >> is done =E2=80=94 s/bar/foo/ is applied to the candidate completions = and that's >> compared to the raw word on the command line > > Hrm, but in both cases (even before the diff) the substitution is > s/$canpref/$origpref/ ? Your explanation here would seem to imply > that in at least the second case the substitution should look like > s/$origpref/$canpref/. Yes. That's why the comment says s/$origpref/$canpref/ rather than s/$canpref/$origpref/ as the code in HEAD says. Perhaps an analogy. Imagine a function that takes an unmetafied string and an array of metafied strings and has to return 0 or 1 according to whether or not the string is in the array, using nothing but strcmp() for comparisons. The function should either metafy the string or unmetafy each string in the array in order, then. (This analogy falls short of explaining why one approach is better than the other.) > The difference is that in the first case > $tmp_buffer is the result of filtering with "compadd ... files" and in > the second case we're altering the elements of $files directly. > >> Adding or removing -Q or {(@)} (or ${(b)}, cf. workers/39080) might w= ell >> be independent of that issue, though. > > I believe the difference here is also compadd -- it performs the > quoting changes that -Q then has to account for. So when we modify > $files directly in the second branch, we have to also emulate the > quote behavior of compadd. My previous suggested patch perhaps didn't > go far enough in that direction? I'm not sure off the top of my head. Perhaps that patch needs an extra ${(q)} somewhere? Or perhaps we should add -Q to the if() codepath? What do callers expect? In general, I think the metafy analogy is valid here: we should define whether $matches contains raw values or quoted values (and perhaps also which form of quoting is used =E2=80=94 presumably ${(q)}) and then ensu= re that both branches conform to that internal API, just like for any char* variable we define whether it's metafied or not. Cheers, Daniel