Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug in completion with curly braces?
- X-seq: zsh-workers 47583
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: "Felipe Contreras" <felipe.contreras@xxxxxxxxx>, "Zsh hackers list" <zsh-workers@xxxxxxx>
- Subject: Re: Bug in completion with curly braces?
- Date: Sat, 21 Nov 2020 15:28:45 +0000
- Archived-at: <https://zsh.org/workers/47583>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-11/69b1ff42-3e60-4b40-8514-9bb0690eb250%40www.fastmail.com>
- 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
- 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==
- In-reply-to: <CAMP44s1suGkR83v82+C8xUUG3J8fwyuwPamujvRUPLcNyQdeJw@mail.gmail.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <CAMP44s1suGkR83v82+C8xUUG3J8fwyuwPamujvRUPLcNyQdeJw@mail.gmail.com>
- Sender: zsh-workers-request@xxxxxxx
Felipe Contreras wrote on Fri, 20 Nov 2020 01:50 +00:00:
> compadd -Q -- 'stash@{0}' 'stash@{1}'
>
> The first completion correctly generates "stash@{", but the second one
> generates curly braces, the third one does the same, and so on ad
> infinitum.
>
I can reproduce this in «zsh -f» 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 «compadd 'foo$bar'» to «compadd
-Q 'foo$bar'»). If that word contains metacharacters (e.g., «compadd -Q
'|| /bin/echo hello world'»), 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
«compadd -Q bar baz» followed by «foo ba{<TAB>», it offers «r» and «z»
as completions, which let you build up «{bar,baz}» and «{baz,bar}»
respectively. Similarly, given «stash@{<TAB>», it presumably takes the
brace for the start of a brace expansion, and the analogous construct
which that behaviour lets you build up is «stash@{\{0\},\{1\}}» or
«stash@{\{1\},\{0\}}» — except that when you press <TAB> 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 «compadd -Q stash@\{{0,1}\}». (Brace
expansion is several layers removed from filenameness checks, which is
why stuff like «ls {-{l,d},/bin}» works.)
You can probably just remove the -Q.
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author