On Sat, Mar 17, 2018 at 12:16:24PM +0800, Clark Wang wrote:

> This seems to work but it does not. For example in the command line
> 
>   # some-cmd f<TAB>
> 
> will become
> 
>   # some-cmd foo'bar
> 
> then you press ENTER and it'll still wait for another ' char.

Oh, I hadn't realized that, you're right. My example was incomplete because 
when I realized that I had to sh-quote the words in wordlist, I used '-o 
filenames' in the comspec (I hit the original problem when I was completing 
filenames), which works:

complete -o filenames -W "foo\'bar aaa bbb" some-cmd

> Actually every word in the -W "wordlist" needs to be sh-quoted twice (with
> ``printf %q'' or the new ``${var@Q}'' syntax). It'll be a bit easier if you
> use an array.

You're right: it does work ! Hey, thanks for pointing out the ${var@Q} syntax: 
I wasn't aware of it. Had a look at the man page, and realized I didn't know 
about the ${parameter@operator} syntax.

This discussion was enlightening, thanks for that, Clark !

Paulo

Reply via email to