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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2535 invoked from network); 21 Nov 2020 15:29:38 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Nov 2020 15:29:38 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1605972578; b=RdRCUubvYYKFgh3k2CXtG6Eo5OTYi2xHr+JDlq8tkGcuXzRA5V0OTQ2zOPvE8oKr2OYE1oa2Yg 7V/FE2k4tDCNLI7T6HdKV0hpqTGLHKEfgjshg4ToeNJE0osPvnmx051xczekgc+MiIm8TRgzfK 0+0LW+X+kA8ZfUMsgHQU2wxY0gf6Q0H26yV6aLRIzvU8ATAnFPkHBDCt+1t/vVv8cLzuQLJ6+f nVkkSmaHxl+UwLhRgH0SuNV661A/q3XA1eh178kdjBPkaQu1IBL9ehdst/V1LaMlKZjWRCU8iU czrBg45seMgT/k2xoWTJACiHNWwwoXcj8rGbH1xBp1ZZhw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout2-smtp.messagingengine.com) smtp.remote-ip=64.147.123.25; dkim=pass header.d=daniel.shahaf.name header.s=fm1 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-20200801; t=1605972578; bh=pCrTW9Xg9RxfRro5ay2pQgYBdiGuWgNKXLPQ/xRXcZQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:To:From:Date: References:In-Reply-To:Message-ID:MIME-Version:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=0RQY1Q7JM+mmcoqH3YxKGxAp7FZ2MsJYUAMJWcDjS/h8A10ksXKgCfZosp7jVb1NVNzaC15uEd fUB5Pit7Qu8JhqY73Ou0VQNaYCvMdljfnKUEh5Ty8bgwyL5u4tlu1tOegEBJbvuDm43UnrhO/d TziM1lNjCoQQY1vnP0A4wWWE350Ggwr6CfhIdz0Ex0/J84W1qF3vKoZ83ZAUKJ3TprRcyLXln0 h8sEIkPslXGIHIXq0xl/s8vZXx529EmdmF2ggwL26WkFtR0rfpfNo2jspKaNVwd3dPGaCPDerO AO0NhFy7mesOj/dCmghh9Fh1+RFVcgLvChvPmJh4s9c5og==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Subject:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=VTD1Sg3HrVhjUm9xiZYYDFN8beGCiGrefev5iDGAGN8=; b=q3GKPTc1znLs4ToOxKFnXWhWrk 3EctPOTZn7QjvUCSGZk9dPKL2xtfzCOdXjHJBSKSoyQ3Bdy349iL1Op1eXVrrrpkQcSpUbgrELBIv 7WJWMvebNrDbtAqzf19hkeWUSzPD7FSpSg2Lf596uOMl+EA3JEcn4SaAxu1a0g7u8mhInlbi5ge2g L7O6//+Ekv4Vp2h545VRoYEKVRDRf9ZBx1wDVweUy+hPc95/kyv33WJNuIPRtrX5ZUF9WU2MXWK2B ycItByVvRxGH1OuX7VgTIqrXTbHCKF4NcDNArPIE4iCOV7S0mIVY30d7ELWiSbyW2gCay0jlTpzJ4 0mIClDoA==; Received: from authenticated user by zero.zsh.org with local id 1kgUpU-000CfF-7t; Sat, 21 Nov 2020 15:29:36 +0000 Authentication-Results: zsh.org; iprev=pass (wout2-smtp.messagingengine.com) smtp.remote-ip=64.147.123.25; dkim=pass header.d=daniel.shahaf.name header.s=fm1 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 wout2-smtp.messagingengine.com ([64.147.123.25]:45987) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1kgUp3-000CW9-Hb; Sat, 21 Nov 2020 15:29:11 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 25236D2E; Sat, 21 Nov 2020 10:29:07 -0500 (EST) Received: from imap37 ([10.202.2.87]) by compute3.internal (MEProxy); Sat, 21 Nov 2020 10:29:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=mime-version:message-id:in-reply-to :references:date:from:to:subject:content-type :content-transfer-encoding; s=fm1; bh=VTD1Sg3HrVhjUm9xiZYYDFN8be GCiGrefev5iDGAGN8=; b=Us2S+/KJ2DFFdBnT5j2rDHQ5dNTIZF8yTC8/2seOef 9x5U8e4SsXE2D+f6bNsFMtYuFedctCqymf4dRRH+XxgWP2gaVdxwdiYfSz0cJA+J tXLHPoYYx7aNzGRMmsISzBqfebsbDp0R4P8wdPrn7bM9lNEqd6Op8+tugC3PuPKN NPk2bbTTnjH23wdiymtk9SXh32h5YP/pWY6ZXBEsgQf+GZ+DXYyndeAWifQ4z6Rj PdxkA26FcoMIU+HE510db5NrLD1JNWgLif5HN84hHipjOGwIrv40kx7m0gPXU9Vz 98UfdmHjZToCApk9/utMart7xFgZWC+TfYI1DPAUbSHw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=VTD1Sg3HrVhjUm9xiZYYDFN8beGCiGrefev5iDGAG N8=; b=cKESuo30xoeYhjeTT3t61sz7+8+0udREI59Ae1THWzWhaSqWGv5z008t9 23MrlFgabqqrMwkeioFOwyadcCCtL6fIUroAYVpXPvLIPD2AHmylpYuqnE2tS58b d33sWzGG2dPuaAZmj/IBZpUidTjArfbT7L+/GbPug899zEwHSsi0pV3DPSXDKf49 nm2chQPtkEzxigG+UghHU05xxdh4+gzVVTJCSW34vWCjDhwDjo9Mki7zL36FNhOu /FL6+EfGP6Puy6YQnzW7KDf3cgdts+ybgfTJDo/1PW6wkaqIRv4peG/Wu6aajVXq 0/XzPAn7F0NnqZnZmuPUySQ3KT1dw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudegvddgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfffgr nhhivghlucfuhhgrhhgrfhdfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmh gvqeenucggtffrrghtthgvrhhnpeefhfekfeevieelleehiefftdekudejledvhfdtjedt geegvdeuffefleehhfdvgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 76746190006D; Sat, 21 Nov 2020 10:29:05 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-622-g4a97c0b-fm-20201115.001-g4a97c0b3 Mime-Version: 1.0 Message-Id: <69b1ff42-3e60-4b40-8514-9bb0690eb250@www.fastmail.com> In-Reply-To: References: Date: Sat, 21 Nov 2020 15:28:45 +0000 From: "Daniel Shahaf" To: "Felipe Contreras" , "Zsh hackers list" Subject: Re: Bug in completion with curly braces? Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 47583 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: Archived-At: Felipe Contreras wrote on Fri, 20 Nov 2020 01:50 +00:00: > compadd -Q -- 'stash@{0}' 'stash@{1}' >=20 > The first completion correctly generates "stash@{", but the second one= > generates curly braces, the third one does the same, and so on ad > infinitum. >=20 I can reproduce this in =C2=ABzsh -f=C2=BB zsh-5.8-259-g00d20ed. I don'= t get a segfault. > I didn't specify file (-f) or any special completion, so why would zle= > attempt curly brace expansion, especially if the words contain curly > braces, and the current character is a curly brace? Inserting the braces into the command line unescaped is correct since -Q= was passed to compadd. (Note that when -Q is not provided, the braces _are_ inserted escaped.) Treating them as starting a brace expansion is also correct, because -Q doesn't disable that part of the grammar. -Q only means that when a candidate completion is inserted into the command line, the inserted word doesn't get escaped (e.g., compare =C2=ABcompadd 'foo$bar'=C2=BB to= =C2=ABcompadd -Q 'foo$bar'=C2=BB). If that word contains metacharacters (e.g., =C2=AB= compadd -Q '|| /bin/echo hello world'=C2=BB), then -Q makes it the caller's responsibility to escape them as needed. Consequently, brace expansion is presumably attempted for the same reason it s attempted when the words don't contain braces. E.g., after =C2=ABcompadd -Q bar baz=C2=BB followed by =C2=ABfoo ba{=C2=BB, it = offers =C2=ABr=C2=BB and =C2=ABz=C2=BB as completions, which let you build up =C2=AB{bar,baz}=C2=BB and =C2=AB{= baz,bar}=C2=BB respectively. Similarly, given =C2=ABstash@{=C2=BB, it presumably = takes the brace for the start of a brace expansion, and the analogous construct which that behaviour lets you build up is =C2=ABstash@{\{0\},\{1\}}=C2=BB= or =C2=ABstash@{\{1\},\{0\}}=C2=BB =E2=80=94 except that when you press a second time, the newly-inserted brace is once again inserted unescaped, which presumably gets handled as the start of a nested brace expansion. As to -f, curly brace expansion is perfectly valid for arguments that aren't filenames, such as =C2=ABcompadd -Q stash@\{{0,1}\}=C2=BB. (Brac= e expansion is several layers removed from filenameness checks, which is why stuff like =C2=ABls {-{l,d},/bin}=C2=BB works.) You can probably just remove the -Q. Daniel