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 5110 invoked from network); 2 Dec 2021 19:45:58 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Dec 2021 19:45:58 -0000 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:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:cc:References:From:In-reply-to:To:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Hbn65m2qKqf7IzINVap6wKOLX6viEmB4oEQ9qhfPgkU=; b=Mqvj1qqBMk+dB27IhMVoCtjYvG UrdVSwUXS04hyCZyKqiGGOCkSZMYJj7SqQnkErbXdEEAYVql38gIeGRoA/A0tAPoCQVzGoej3QKVH folKAm/2yGpM13R/xe1KIXBHWxb1BYSrFohy3Q/b6WlJ+qNK5PG2kdDWQEiCx7M5W6b8klZvlEQN2 BFUPJWrDXc12SVEVpCxCr+AqBNZWiC9EVuPaTX7F1iSsHU5kd/SCvj2wjkxeZ2run4qZF2Jg3zz2+ I6mN1HhNqAzkGHKzU50FePG0mET+6iULJbCcJGhSMZXSCaCLfXMb9MbfKbYAPLnlQ94uY0L7KB/hP O5eWgjIA==; Received: from authenticated user by zero.zsh.org with local id 1mss1j-000Jlo-W9; Thu, 02 Dec 2021 19:45:56 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mss1B-000JTH-Lp; Thu, 02 Dec 2021 19:45:21 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.94.2) (envelope-from ) id 1mss16-000HO3-HW; Thu, 02 Dec 2021 20:45:16 +0100 To: Zsh hackers list In-reply-to: From: Oliver Kiddle References: <69b1ff42-3e60-4b40-8514-9bb0690eb250@www.fastmail.com> <23476-1606260115.748247@tHME.aGU-.iDnX> cc: Felipe Contreras Subject: PATCH: bashcompinit quoting (was Re: Bug in completion with curly braces?) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <66837.1638474316.1@hydra> Date: Thu, 02 Dec 2021 20:45:16 +0100 Message-ID: <66838-1638474316.539731@g_Nn.BL1d.lQYb> X-Seq: 49630 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: On 24 Nov 2020, Felipe Contreras wrote: > > We could do something like the following in bashcompinit to special case > > only space suffixes: > > > > - compadd -Q "${suf[@]}" -a matches && ret=0 > > + compadd "${suf[@]}" - "${(@)${(Q@)matches}:#*\ }" && ret=0 > > + compadd -S ' ' - ${${(M)${(Q)matches}:#*\ }% } && ret=0 > > Yes, that should work. Although I think bash would add two spaces if > -o nospace isn't specified. I never did anything further with this a year ago. Revisiting it and trying to find examples, that approach does seem to be more compatible with bash. bashcompinit did acquire two uses of -Q. The other case is for filename completion. The bash complete builtin has at some point acquired a noquote option which will "Tell readline not to quote the completed words if they are filenames (quoting filenames is the default)." So I think the right change in that position is merely to remove the -Q. The patch does this. Bash has a few newer complete options and a new compopt builtin for changing the applicable options from within a bash completion function. It doesn't look especially hard to implement these but I'm not sure how wise that is. bashcompinit was possibly a mistake to begin with. If people are using it then supporting newer features would improve their experience. And maybe give them less motivation to write a native zsh function. Oliver diff --git a/Completion/bashcompinit b/Completion/bashcompinit index b278ac8f4..adb659ca1 100644 --- a/Completion/bashcompinit +++ b/Completion/bashcompinit @@ -24,9 +24,10 @@ _bash_complete() { if [[ ${argv[${argv[(I)filenames]:-0}-1]} = -o ]]; then compset -P '*/' && matches=( ${matches##*/} ) compset -S '/*' && matches=( ${matches%%/*} ) - compadd -Q -f "${suf[@]}" -a matches && ret=0 + compadd -f "${suf[@]}" -a matches && ret=0 else - compadd -Q "${suf[@]}" -a matches && ret=0 + compadd "${suf[@]}" - "${(@)${(Q@)matches}:#*\ }" && ret=0 + compadd -S ' ' - ${${(M)${(Q)matches}:#*\ }% } && ret=0 fi fi