Re: [RFC nftables PATCH] nft: add bash completion script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Pablo,

2016-02-15 20:56 GMT+01:00 Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>:
> Hi Giuseppe,
>
> On Fri, Feb 05, 2016 at 05:53:02PM +0100, Giuseppe Longo wrote:
>> The following patch adds a bash completion script
>> which permits to complete nft commands.
>>
>> To install it:
>> - cp files/nft-completion /etc/bash_completion.d/
>> - . /etc/bash_completion.d/nft-completion
>>
>> The following commands are supported:
>> - nft add table <family> <name>
>> - nft list table <family> <name>
>> - nft list tables
>> - nft list sets
>> - nft list chains
>> - nft list ruleset
>> - nft list set <table> <name>
>> - nft add set <table> <name>
>> - nft add element <table> <set>
>> - nft add map <table>
>> - nft flush table <family> <table>
>>
>> Most probably this won't work with sudo, since there
>> are some nft commands into the script.
>>
>> A second patch to add completion in interactive mode
>> will come.
>>
>> This is only a draft,
>> any feedback is appreciated.
>
> Could you explore adding code to inquire the parser on the next
> possible tokens ahead? That would greatly simplify the shell script
> for bash autocompletion. We should be able to reuse this from
> libreadline too.
>
> I know what I'm asking is a bit more difficult, but it would help us
> reduce the amount of code duplication and will reduce the maintainance
> burden.
>
> Let us know, thanks!

Sure, I've looked quickly at bison doc and thought the following idea:
We can add a new nft command like "nft complete" to inquire the parser,
which will print all the possible word since we have a parse tree.

in that way, the bash script will be able to complete the command.

Also, do you confirm that we will skip objects like tables name, chain
name, and so on?

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux