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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7861 invoked from network); 22 Nov 2020 20:36:27 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Nov 2020 20:36:27 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1606077387; b=KKF02AqZWBuzl1Qe8XBrBY2XgWPIH8Ht3mj7uIY/NSMeCzeidvRcOqAl/GC+s3P4atkAsG9NBb M+7M9EQ7z5Z7hBh8n99cMnY3tKxTt6Nb+efgIuwBkJIhJxA+n44p+lBW9VpcdZe5vaWsgzxMBK qfL8Sx7iEILxiHn7zXLoLxUWGgrCI2ZhPjfQZ0GkDir4a5gNlEGRji9PH5vLmlQte2JeiEipNY QTDHpEEhltGTsDSM0vHq37Orl7clUtUftMxMVg7jVmZtRucIh6qvDbNpI/Ip5AmGqtL6T3SCt1 LfP+sJj/xcyrHrTx6dJfuGA7deUH//66loxjjJwhA9IpzQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f182.google.com) smtp.remote-ip=209.85.167.182; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1606077387; bh=2OifVAbQarwhqwtQtXeS8SacA6RXUlANpdcWkxe0A04=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=qawEnQC+ErZoZX25AbU7Br12Ql7JqIRvy1oljMnr9xmfcMHnIFfv1RGgUGumr6GFY4xRepLwsp eGaMJftC9XJw+oMb0Z/i4pKEHmmh+VAcycBS7RnLXlAa2QHenbgdbwk4XtamJ3gLAynpwIt3i6 wrlSWTCiXGlpwY6eTskqRFocdtNcEha4xMeAIFyN6l4uQrse3FIqwjJLDey1Cr4vCUDAp3+X+0 wyWcZ/9io/WONjdqntkOtvkPH5U4QlUR54Jy2FOq2YOyxANS5MJcBOQvLKitRF+A9/Zcx2rge9 PjGC8HAEJ4fv/azm8mEzJm+KeVGGFMbiK8NzZHkvTqh44Q==; 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-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Aabviy5q7PYih1FzKDddt22kZSf+ARlXYSD7Rc+v/A4=; b=H4CtEPgz29mLSf3oALmRFq1cng KldKsKAMOCXN+rWyDVDr9w9AXyLGJ/My1XZ11w8GijuKVNHjh14nl/hMkWQo+qLoXEV1Zqc9/lCcB n7rkZzwJ2vydG+7m06H9Eu9M3ekYPgZO+hVTmsBJOd+v3VZWmOOANJwHQJSJizo4iVIbgOtU396aL BVaBSISHi6duY3Ny3kOBcWeEMPPQ3rAJ53/eofgedERxbBhpVxwjvfPYPP57IK1zUFHZVPstwourZ KgzNVkqUPLUU5YTB1yM/uLcaIJEGoncouwJZC+Ltx2JorQs+lwrAL8E8czfrVRKzQku6iRoGiSqys kpupgprA==; Received: from authenticated user by zero.zsh.org with local id 1kgw5w-0008Ik-IC; Sun, 22 Nov 2020 20:36:24 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f182.google.com) smtp.remote-ip=209.85.167.182; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oi1-f182.google.com ([209.85.167.182]:38476) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kgw5c-00088k-Sg; Sun, 22 Nov 2020 20:36:07 +0000 Received: by mail-oi1-f182.google.com with SMTP id o25so17409252oie.5 for ; Sun, 22 Nov 2020 12:36:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Aabviy5q7PYih1FzKDddt22kZSf+ARlXYSD7Rc+v/A4=; b=PE0xpaHuac1FNlbQEpv+rie6y6og3xAhtEil0hY1O8TecPc1P0gmfulg6zZ7fKyCmM gKJTiEHSq5aT9O70RBaXpNZW70aZkl+ypQniYhKqcz6dY0lahrds78JgTwnJjhfpnf9U HJDylswN+mCcPBjPvmDY1x7RtED94bQNrPnBwRMfFGY4NyOyn9WZFgIbMY0AV5N/ga3x D4DqZDYK0QMQ8lywNiRgCuj8wVZKMHECCG2+iFXq38At7OzqLQUSjpCHxWPSJWzzh3oO odxW1FHg0jDZ2OYosRDIOfwE9g1SMCXhVbWEhsCw0bnXjKwJCUsZceMR31zEfSo08dHm /1vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Aabviy5q7PYih1FzKDddt22kZSf+ARlXYSD7Rc+v/A4=; b=i9/CpoTdl1y1FYx/hD0Sk7492cooOparXIMpfWiaHIPjd4aH0apQDbK6xtTbPb8okF Jkg1izTgfro/b6iedGtQo/bMocNBhFctouchWexHOO4lmt9FixgCQ07aDoc8Mn+J7/+k mPnCQ1MMdNiZpgttGIGo+70E0xwbW3pOTHAqfT7Ci/46r0eq1GlHLQXyADveLWR5591U FudDW8opjejoNnN1OSepIP07NkEO46R8t1CA2tmeS2BBWGUzd8XYXQz8dSd/OlpUhZae DbS/VUNYM1T2k0gEPDWqOZ1/AozPsxmU5hGH69ea0jLzVCoe3UjmOy9CzDbGi6w5dZjz JgFg== X-Gm-Message-State: AOAM531pi6w8Jo5xcFUN/1NR6bPYh6tk3gGBSD2A6EyS3RQPmddP6K9P 7SWs0XSZO4Q3AGJnqGOgn57UXZsoK78DjNN0rHh+8A== X-Google-Smtp-Source: ABdhPJxqtstQpzcIL0eXhjbrp9btFKRe9elEv7h/Y38ceeG2w3D9Pvwhjblkq3IeOSogfOv0AcBLaPo6cRRyoTf9uks= X-Received: by 2002:a05:6808:8c8:: with SMTP id k8mr3464477oij.84.1606077363468; Sun, 22 Nov 2020 12:36:03 -0800 (PST) MIME-Version: 1.0 References: <69b1ff42-3e60-4b40-8514-9bb0690eb250@www.fastmail.com> In-Reply-To: From: Bart Schaefer Date: Sun, 22 Nov 2020 12:35:52 -0800 Message-ID: Subject: Re: Bug in completion with curly braces? To: Felipe Contreras Cc: Daniel Shahaf , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47594 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: On Sat, Nov 21, 2020 at 6:58 PM Felipe Contreras wrote: > > So the options are: > > 1. Fail the completion > 2. Complete something I didn't ask for (but it's close) > 3. Complete correctly what I asked for > > I'm saying if 3 is not feasible, then perhaps 2 would make sense > rather than 1. It's at least something. It's up to your completion function to tell it that #2 is OK, and what to offer in that circumstance. That's one thing e.g. _alternative is for. In this specific example, though, any time an unquoted "{" appears on the command line at the time completion is invoked, it's being treated as the start of a brace expansion and therefore removed from the match comparisons so that completion can try to fill in a comma-separated list of replacements. This does appear to be related to a couple of actual bugs, because "setopt ignorebraces" is supposed to disable this, but does not do so correctly. Before I get into that, here's a hack to take advantage of the brace-completion behavior to get something that works the way I think you would like: _foo() { local stashes=('stash@{0}' 'stash@{1}'); if [[ $words[CURRENT] = *\{* ]] then compadd -Q -d stashes ${stashes//\{/} else compadd -Q -a stashes fi } This just says "if there's already a brace on the line, pretend this is a brace expansion but include the braces in the menu display". As to the bug ... there are actually a few of them, all inter-related. 1) _comp_options includes "NO_ignorebraces" so isset(IGNOREBRACES) is never true in zle_tricky.c:get_comp_string 2) Even if that's removed from _comp_options (and set in the caller context), when the brace is added to $PREFIX it is escaped with a backslash, so it no longer matches the string on the line and completion fails 3) When IGNOREBRACES is set, the $debug_indent string in _complete_debug is mis-handled 4) Possibly as a consequence of that, invoking _complete_debug from outside GDB with ignorebraces causes the shell to exit (no reported error, it just exits) #3 is relatively easy to fix but I won't yet in case someone can track down #4 (I've had no luck).