On Mon 03 Jan 2022 at 21:22:44 (-0500), Greg Wooledge wrote: > On Mon, Jan 03, 2022 at 11:56:57PM +0000, Long Wind wrote: > > Thank Greg and David! > > > > i type "ifdown <TAB><TAB>", it add lo automatically, > > wireless device isn't shown, though wireless connection works well > > > > i think "ip a" can list wireless device > > Well, it sounds like _configured_interfaces on your system only finds > "lo", whereas _available_interfaces finds a larger set. > > _configured_interfaces is apparently defined in > /usr/share/bash-completion/bash_completion and includes this code: > > if [[ -f /etc/debian_version ]]; then > # Debian system > COMPREPLY=($(compgen -W "$(command sed -ne 's|^iface \([^ > ]\{1,\}\).*$|\ > 1|p' \ > /etc/network/interfaces /etc/network/interfaces.d/* 2>/dev/null)" > \ > -- "$cur")) > > If I'm reading that sed command correctly, it only works if there is > precisely ONE space between "iface" and the interface name. > > Perhaps your iface lines in /etc/network/interfaces are using tabs, or > more than one space, between the word "iface" and the interface name. > If so, that's why this particular bash-completion function doesn't > return it. > > It's also possible that your desired interfaces aren't defined in > /etc/network/interfaces at all. You might be using Network-Manager > instead, on that system. That's perfectly valid, but this bash-completion > function won't see those interfaces.
There's another assumption in that pattern: that /e/n/i contains source /etc/network/interfaces.d/* That line could be absent, pointing somewhere else, or it could be the subtly different source-directory keyword that filters the filenames in the directories to a particular charset. > The _available_interfaces function (used by dhclient's completion function) > is very different. It calls "ifconfig -a" or "ip link show" and then > parses names out with awk. Or at least it tries to. Obviously that will > give different results, if your interfaces are defined by Network-Manager, > or systemd units, or if you used liberal whitespace, etc. > > Have I mentioned yet that bash-completion has some notoriety for being > fragile and a bit broken at times? I don't use it personally. If it > works for you, that's great. But it's far from perfect. Cheers, David.