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,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13130 invoked from network); 23 Nov 2020 06:46:51 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Nov 2020 06:46:51 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1606114011; b=gWtb8xidPqmSeCSsW8fdPAxnmFSo0WkFZooxmhHycYoe5NVUqFVHiqbj0IO4UkED51yVMWep+K E9rPxqkm2me296V6N63JVXiOPaOeSwsPSxEGUqPMN/sMm5l7VTKlSHhvHWXZnINPlqStK5otev Q1suL7Em+JTuWVsyNc80foB9cPhNaapv541NxVeRWlL5EFLzjSsnFo8jlPyP4ZZ5RUlEVvytvI oWqfs4jkbwCHjSwdgA1tJIzJ0kCGN3wtTXz5KF1clxU+HEBfGIYEVHD7cAzHqAEb9rBPx3pHQW 6LcYiSu6a7+ohQ8LBCO4hdXYr8tsUfUy+/cIXhaSx2aAhQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wm1-f43.google.com) smtp.remote-ip=209.85.128.43; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1606114011; bh=ygDGBy1D1zK28WJvwNyUJ6Po5AUpnVnbt99MPh8moI8=; 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=tnXkq5hynwsT0sy8VYyItmow8Ol/MM3m+60TapTkWF5K8l498BLM90GcRXVzlrQFqJjZa8vxl0 b8tswqsKd4lWXcmGOplvnKpJoomTQQXuQHKKo+F+V4bQa1G1Uf4aLarhdV3uHrOm81PniNQTbD xbSY3XJgA4286zXEHsaByUnB/+yiKwmSkQhdesmMwxanD7JbddzpY7L+EIyJbuKoqQvSdm8ekp JdilW34D9VA+CWRq5TtDl1wMNiRG2CJAMlyEg9KE/21VYYbJwyhfmHBiQCvy6gITVOLR/sOQ24 J+JJ2COMrSZp5Aj4j+tOitj5w0CfhudbcUq+WH6mzgxxXw==; 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=AvwbCat9ozS6719fmUbU4zVomSvYvz6sHJ6MgU5ToOw=; b=WUK3uwKHjT1rjmJ2nTaMoiWRp7 vBs8uQpURhUzOsLAoaCmp67+APkbFqexUf9VCXvlUWAhYQ9Nem4Yhc+eAFYPeLwVpwAEem7kQyT3c NU350EzF2t/IENZT+sexzf/XCFiCA14/L2ERDuaRWRpFilRsIS8A2XLk5qeH7rnQfZfQrE1FTXqwn vSbrN7xzlDAz+GxJ80qwd5qxePR2EGSOFnQrAM1ZLgJAH7FrnuMjUebXAUFZ2psUiFhO95uAodV/j Uj80bv+8PjDaxCtsdjkDaYJgkGDEDJytSApgFlAzDTHxFuFDK0Nlqt8Kf0E7vqUeRrsSH2rceePWs o+uFHFfw==; Received: from authenticated user by zero.zsh.org with local id 1kh5cd-0000xl-40; Mon, 23 Nov 2020 06:46:47 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f43.google.com) smtp.remote-ip=209.85.128.43; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wm1-f43.google.com ([209.85.128.43]:55469) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kh5cL-0000oR-6j; Mon, 23 Nov 2020 06:46:30 +0000 Received: by mail-wm1-f43.google.com with SMTP id c9so16840064wml.5 for ; Sun, 22 Nov 2020 22:46:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AvwbCat9ozS6719fmUbU4zVomSvYvz6sHJ6MgU5ToOw=; b=twnxh5sIy9gJIGJxB01GYK9vo3LEhycVSeG4cLYKOkO4H7H7jJfFXxv6jHTbOXDofl aDsVlj9gyylY33foboABp+/VGf1pl3zNYmDq6TeovsfP28GZcYFn/57wX/z6NksZVAna JVmBmZoMK3aPYSNG2HUMUXMHM0EUpMpsR1iJNxUV+KT/qv/d3+mIepwf/NCJ+W9U6G/R eUysrtV6Vik+/ML7PfkHNOMYSzJ3WUL44+nlcPuMuxFy08QKBKhcS1f5942iZdVnGo+g 2RO9FXLZgbrcSFdGFiLsii9vbCjurF8jdM+GQ/RXj5mhYnzd6efXpN6PNWYT9lg3sZcu 1mfA== 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=AvwbCat9ozS6719fmUbU4zVomSvYvz6sHJ6MgU5ToOw=; b=O6O4phZTHAnQ7zENaA1HcN3PekW1OQaS87t6CkFGyhYV4+CdP8zBfnpPheygpW6Xjw i0zIg6fNhFa1mA9NeqsRbaf9oNK7Y2+aTbKJmMr6i1nE/imzPwq1q8WBDm0oShqvVM++ hW8Rxq/Taxxk2MUk/km4fEZvAkJBCznItde0WjUmqpYyq5m9UoeKaoM2VaWr46K2KZ8d BOz6IJCrKQrTUgDR/QBcp1EJJg8bLrdV4ZNNRB+kspHt6+hmNRmzVFEgEhtTSRJeaflr mh/53DVJbGk+L6TRncLruzRDIeUJWXHQxz5X2PzBWefi98cdRkBZ+NziFyC95h84SUpw 7OZA== X-Gm-Message-State: AOAM533dJatCpVcm3At0Wr6F99Skit1ECkpbSs3MIzm0ShOKRe5QHk9o ts+zBK8LS51N/lPAzPDc5/rCTX9BVNznLSOzlaNn7NsVjqbtTA== X-Google-Smtp-Source: ABdhPJwORRJqrOpD+F9C5yzifLD1NXcyAxam8nBQeJTdxXk4Ku62ajdYBTBxHgpWsiMkVc2o5yltzQL83mlPRGWeTdU= X-Received: by 2002:a1c:41c4:: with SMTP id o187mr16395107wma.48.1606113988840; Sun, 22 Nov 2020 22:46:28 -0800 (PST) MIME-Version: 1.0 References: <69b1ff42-3e60-4b40-8514-9bb0690eb250@www.fastmail.com> In-Reply-To: From: Felipe Contreras Date: Mon, 23 Nov 2020 00:46:17 -0600 Message-ID: Subject: Re: Bug in completion with curly braces? To: Bart Schaefer Cc: Daniel Shahaf , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47602 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 Sun, Nov 22, 2020 at 2:36 PM Bart Schaefer wrote: > > 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. I'm not using _alternative, I'm using compadd. If compadd doesn't do what I told it to do, then #1 it is. > 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 > } Yeah, this almost works, but I'm not interested in hacks. My real function is something like this: __compadd () { compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} } I'm not going to add dozens of lines of code just for this corner-case depending on the value of $1. If compadd doesn't work on this case, then it doesn't work on this case. > 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). So, in theory if the user has ignorebraces set, there would be no need to use quotes for the curly braces? Cheers. -- Felipe Contreras