Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #243665
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: why bash completion sometimes doesn't work? |
| Date | 2022-01-04 03:30 +0100 |
| Message-ID | <DBHKh-7Lc-3@gated-at.bofh.it> (permalink) |
| References | (1 earlier) <DBo4V-4oV-1@gated-at.bofh.it> <DBuDn-8jx-5@gated-at.bofh.it> <DBBYd-4lx-1@gated-at.bofh.it> <DBDnk-53X-11@gated-at.bofh.it> <DBFp8-6fB-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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.
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.
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
why bash completion sometimes doesn't work? Long Wind <longwind2@yahoo.com> - 2022-01-03 06:30 +0100
Re: why bash completion sometimes doesn't work? Greg Wooledge <greg@wooledge.org> - 2022-01-03 13:30 +0100
Re: why bash completion sometimes doesn't work? Richmond <richmond@criptext.com> - 2022-01-03 15:50 +0100
Re: why bash completion sometimes doesn't work? Long Wind <longwind2@yahoo.com> - 2022-01-03 21:20 +0100
Re: why bash completion sometimes doesn't work? Greg Wooledge <greg@wooledge.org> - 2022-01-03 21:30 +0100
Re: why bash completion sometimes doesn't work? David Wright <deblis@lionunicorn.co.uk> - 2022-01-03 22:50 +0100
Re: why bash completion sometimes doesn't work? Long Wind <longwind2@yahoo.com> - 2022-01-04 01:00 +0100
Re: why bash completion sometimes doesn't work? Greg Wooledge <greg@wooledge.org> - 2022-01-04 03:30 +0100
Re: why bash completion sometimes doesn't work? Long Wind <longwind2@yahoo.com> - 2022-01-04 03:50 +0100
Re: why bash completion sometimes doesn't work? Greg Wooledge <greg@wooledge.org> - 2022-01-04 04:00 +0100
Re: why bash completion sometimes doesn't work? David Wright <deblis@lionunicorn.co.uk> - 2022-01-04 20:40 +0100
csiph-web