[Bash-completion-devel] iptables-bash_completion 1.4 - Bash shell programmable completion for ip[6]tables

AllKind AllKind at fastest.cc
Sat Feb 6 22:06:03 UTC 2016


On 06.02.2016 12:21, Ville Skyttä wrote:
> On Tue, Feb 2, 2016 at 1:01 PM, AllKind <AllKind at fastest.cc> wrote:
>> Good day!
>>
>> I've written a fairly huge and complex completion for iptables and
>> ip6tables. I know there is already a version available in bash completion.
>> But this one is way more powerful.
>
> Wow, looks like a lot of work has gone into this.

Indeed, quite some :)

>
>> Would be nice if you could take a look at it!
>
> Not sure what kind of feedback are you looking for, but here's my
> thoughts after a few minutes with it:
>

Actually I thought of review for inclusion into bash-completion.
Now reading your answer I'm of course also very happy about any hint and 
feedback. I did most of the work in 2014. After that I found no time to 
go further. So I especially don't know about changes in bash-completion 
since then.

> Not sure if you're proposing it, but this is way too large and
> specific for us to maintain in bash-completion, we have very little
> manpower available these days. Have you considered submitting this for
> inclusion in upstream iptables?
>

I thought it might be too huge and specific, but there's one thing:
The successor of iptables - nft (nftables) - is already out and is 
actively developed and deployed. Over the past two years almost no new
features were added to iptables. With it becoming deprecated I do not 
think that will change.

If I get it to upstream, the downside is, it's up to the packager of the 
distro, or the user itself, to take care of it becoming available.

Also I could still update it to changes made in the future.

> When completing "iptables <TAB>" or "iptables -<TAB>" as non-root,
> there are no completions. Seems that the completion tries to run
> "iptables -S OUTPUT 1" but that's not allowed as non-root so
> apparently it stops there. I don't think this is good, the completion
> included in bash-completion happily completes for example options
> starting with a dash as non-root.

Ok, I see. Just remove that on line #572:
"$str_app" -S OUTPUT 1 &>/dev/null || return
Most things will start working.
iptables <TAB> ... will make a dash will appear as completion.

>
> When completing "iptables -<TAB>" (as root), the short -A etc options
> as opposed to --append are given. I don't think this is very user
> friendly; people who need the completions listed are more likely to be
> able to work with the long completions than the short ones. This is
> the reason we output the long options in bash-completion where
> available.

If you type a second dash and hit <TAB> only the long options will be shown.
The reasons why I did it like this are:
Match and target extensions of iptables just have long style options, 
while the "base" options have both. In situations when both are valid, 
it is easier to distinguish between them. It's easy to view both in long 
style by entering another dash before attempting completion.
Also iptables commands can become long, so it's space saving.

But if that is a problem, I'm quite sure I can work out a solution with 
an environment variable, that by default just shows long options.

>
> The installation instructions advice to drop the file to
> /etc/bash_completion.d. This is the deprecated backwards compatibility
> dir, the instructions should be updated for dynamic loading with
> bash-completion 2.0 (see "I author/maintain package X..." in
> bash-completion's README).

I see. Didn't read that since v1.9. Will update that.

Thank you for you answer!

Best regards,
AllKind




More information about the Bash-completion-devel mailing list