Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: bashcompinit quoting (was Re: Bug in completion with curly braces?)
- X-seq: zsh-workers 49630
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Cc: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- Subject: PATCH: bashcompinit quoting (was Re: Bug in completion with curly braces?)
- Date: Thu, 02 Dec 2021 20:45:16 +0100
- Archived-at: <https://zsh.org/workers/49630>
- In-reply-to: <CAMP44s2d5+yHtdCvGDW92vfcbpV=Wn3+-yG74EdST-dJXFZn2A@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAMP44s1suGkR83v82+C8xUUG3J8fwyuwPamujvRUPLcNyQdeJw@mail.gmail.com> <69b1ff42-3e60-4b40-8514-9bb0690eb250@www.fastmail.com> <CAMP44s1B8sv5Xe-Mvm8peiJ7H4e2oMgTPd8Si4QxcLD5PyaPnQ@mail.gmail.com> <CAH+w=7ZcJ67eq1cKuSDtb_XxOmcyuk2Esw1ebVSgGhXSAx1V9g@mail.gmail.com> <CAMP44s3MSx6_Zkz-vwy4ayPr-9Zdg1M6xfcmALzVyqb01w2zBA@mail.gmail.com> <CAH+w=7a0ArrzE-ct510rS=L7b2EryyuAYSM+vtMg02a-yFd3KQ@mail.gmail.com> <CAMP44s3yz60cAo5xwn_oJjZvvhVY5H9go+KXZ9WT5J_37pe2Dg@mail.gmail.com> <CAH+w=7af7n8NH5b-8Vi2MUWAzbC7-=RQDLX1kCh1R58oMgTLUw@mail.gmail.com> <CAMP44s1AOsnpqvVF2FAb7XRx3E4sfFV3-=xDfvk1WTMgWGcdYg@mail.gmail.com> <CAH+w=7bAL3XO0HW59EDsM2rzTrEbyevWNuGoBUEwt7N9B4-WyA@mail.gmail.com> <23476-1606260115.748247@tHME.aGU-.iDnX> <CAMP44s2d5+yHtdCvGDW92vfcbpV=Wn3+-yG74EdST-dJXFZn2A@mail.gmail.com>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author