scop / bash-completion

Programmable completion functions for bash
GNU General Public License v2.0
2.9k stars 380 forks source link

_comp_compgen_available_interfaces returns trailing colons #1129

Closed scop closed 6 months ago

scop commented 6 months ago

Describe the bug

SSIA.

To reproduce

iftop -i <TAB>
...        lo:               ...

Expected behavior

Available interfaces shown with no trailing colon.

Versions (please complete the following information)

Additional context

Regression in b60353508eb470515f1063a1e1a75bdf1fda730f

Debug trace

akinomyoga commented 6 months ago

Ah, this change is the problem:

https://github.com/scop/bash-completion/commit/b60353508eb470515f1063a1e1a75bdf1fda730f#diff-a4757074ff650000804fd3eaabe9b0a9e02e33040ca5b8afd4c0275fc5f3e136R1694

I don't remember why I did this change. I possibly tried to handle it in the awk script and removed %[[:punct:]], but I later gave up handling it in the awk script forgetting to restore %[[:punct:]].

yedayak commented 6 months ago

Note that this also breaks interfaces that look like this veth0@veth1, _comp_compgen_available_interfaces returns the entire thing when it should only return veth0

akinomyoga commented 6 months ago

Thank you for the information. I'd like to confirm. Do you mean "veth0@ or veth1@"? Or is it actually veth0@veth1? I don't think the latter was broken by the change because veth0@veth1 cannot be modified to veth0 by "${generated[@]/%[[:punct:]]/}", i.e. it was broken from the beginning if you mean veth0@veth1.

yedayak commented 6 months ago

Thank you for the information. I'd like to confirm. Do you mean "veth0@ or veth1@"? Or is it actually veth0@veth1? I don't think the latter was broken by the change because veth0@veth1 cannot be modified to veth0 by "${generated[@]/%[[:punct:]]/}", i.e. it was broken from the beginning if you mean veth0@veth1.

I mean the latter veth0@veth1, I guess it was broken even before this change

akinomyoga commented 6 months ago

Thanks! So, something like "${generated[@]%%[[:punct:]]*}" might be better.

scop commented 6 months ago

Oops, I somehow failed to follow the discussion here. It's likely things were broken also before this changes, but let's continue the discussion about the correct behavior in https://github.com/scop/bash-completion/issues/1133.