Re: compgen -W doesn't split wordlist containing single quotes

2018-03-19 Thread Clark Wang
On Mon, Mar 19, 2018 at 9:52 PM, Chet Ramey wrote: > > `-o filenames' would append `/' to a word if the word is coincidentally a > > real existing dir name. How can I ask it not to append the `/'? > > You can't. That's the implication from my second paragraph. > OK. I'll

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-19 Thread Chet Ramey
On 3/17/18 10:49 PM, Clark Wang wrote: > You haven't told complete that you want the words to be quoted. If you > install the completion using the `-o filenames' option, you will get > filename-like quoting. > > > `-o filenames' would append `/' to a word if the word is

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Clark Wang
On Sun, Mar 18, 2018 at 1:18 AM, Chet Ramey wrote: > On 3/17/18 12:16 AM, Clark Wang wrote: > > On Sat, Mar 17, 2018 at 1:00 AM, wrote: > > > >> > >> It works correctly if the single quote is itself quoted. Our test > wordlist > >> would then be:

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Paulo Marcel Coelho Aragão
On Sat, Mar 17, 2018 at 2:06 PM, Chet Ramey wrote: > Processing the word argument to -W honors shell quoting, in order to > provide a simple way to return words containing shell metacharacters and > characters in $IFS. There is a sentence to this effect in the texinfo >

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Chet Ramey
On 3/17/18 12:16 AM, Clark Wang wrote: > On Sat, Mar 17, 2018 at 1:00 AM, wrote: > >> >> It works correctly if the single quote is itself quoted. Our test wordlist >> would then be: "foo\'bar aaa bbb" >> >> paulo@monk:~/tmp$ compgen -W "foo\'bar aaa bbb" -- a >> aaa >>

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Chet Ramey
On 3/16/18 1:00 PM, marcelpa...@gmail.com wrote: > Bash Version: 4.4 > Patch Level: 12 > Release Status: release > > Description: > compgen -W "wordlist" doesn't split wordlist on $IFS if wordlist contains > unquoted single quotes. For instance, this wordlist, "foo'bar aaa bbb", won't > be split

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Clark Wang
On Sat, Mar 17, 2018 at 7:32 PM, Paulo Marcel Coelho Aragão < marcelpa...@gmail.com> wrote: > > 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. > > On a second thought,

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Paulo Marcel Coelho Aragão
> 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. On a second thought, sh-quoting twice with ${var@Q} won't work as expected in this case, since it encloses the expanded value

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Paulo Marcel Coelho Aragão
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 > > 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

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-16 Thread Clark Wang
On Sat, Mar 17, 2018 at 1:00 AM, wrote: > > It works correctly if the single quote is itself quoted. Our test wordlist > would then be: "foo\'bar aaa bbb" > > paulo@monk:~/tmp$ compgen -W "foo\'bar aaa bbb" -- a > aaa > paulo@monk:~/tmp$ compgen -W "foo\'bar aaa bbb" -- b

compgen -W doesn't split wordlist containing single quotes

2018-03-16 Thread marcelpaulo
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale'