You are not logged in.

#1 2015-12-18 16:23:28

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

[SOLVED] Bash auto completion script: compgen question

Hi!

I'd like to understand whether one can use compgen to print an array of array of strings (ie: an array of sentences).
I know this works:

COMPREPLY=( $( compgen -W "0 1" -- ${cur}) )

and prints
"0        1".
What i'd like to achieve is something like:
"0 to disable       1 to enable"
(or, better still, breaking the line: each sentence on its own line).

Is this possible?
Thank you in advance!

Last edited by nierro (2015-12-21 12:20:28)

Offline

#2 2015-12-21 12:11:20

respiranto
Member
Registered: 2015-05-15
Posts: 479
Website

Re: [SOLVED] Bash auto completion script: compgen question

Use single quotes to encapsulate an "inner argument".

compgen -W "'0 to disable' '1 to enable'" -- ${cur}

However, I doubt this being what you actually want, since when used in an autocompletion script, '0' will autocomplete to '0 to disable' and '1' analogously, which your program probably cannot parse.

Offline

#3 2015-12-21 12:20:05

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

Re: [SOLVED] Bash auto completion script: compgen question

Yes...you're obviously right...i didn't think about that.
Thank you very much for the explanation!

Offline

Board footer

Powered by FluxBB