Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong network interface name if the name is long #1089

Open
3 tasks done
hellodword opened this issue Jan 7, 2024 · 0 comments · May be fixed by #1090
Open
3 tasks done

Wrong network interface name if the name is long #1089

hellodword opened this issue Jan 7, 2024 · 0 comments · May be fixed by #1090

Comments

@hellodword
Copy link

hellodword commented Jan 7, 2024

Describe the bug

network interface name get truncated with ifconfig

To reproduce

$ ip link show up
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
3: nameislong: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000

$ ifconfig 
lo        Link encap:Local Loopback
eth0      Link encap:Ethernet
nameislongLink encap:(hwtype unknown)

_comp_compgen_available_interfaces()
{
local PATH=$PATH:/sbin
local generated
_comp_compgen -v generated split -- "$({
if [[ ${1-} == -w ]]; then
iwconfig
elif [[ ${1-} == -a ]]; then
ifconfig || ip -c=never link show up || ip link show up
else
ifconfig -a || ip -c=never link show || ip link show
fi
} 2>/dev/null | _comp_awk \
'/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }')" &&
_comp_compgen -U generated set "${generated[@]}"
}

Then the _comp_compgen_available_interfaces -a will return nameislongLink instead of nameislong

Reproduce:

sudo tunctl -t nameislong
sudo ip addr add 10.23.45.0/24 dev nameislong
sudo ip link set dev  nameislong up

# TAB
curl --interface nameis

Expected behavior

Versions (please complete the following information)

  • Operating system name/distribution and version: NixOS 24.05.20240102.bd645e8
  • bash version, echo "$BASH_VERSION": 5.2.21(1)-release
  • bash-completion version, (IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}"): 2.11

Additional context

It's bug of upstream inetutils, but maybe we can simply use iproute2 as default choose

ip -c=never link show up || ip link show up || ifconfig

ifconfig || ip -c=never link show up || ip link show up
else
ifconfig -a || ip -c=never link show || ip link show

@hellodword hellodword linked a pull request Jan 8, 2024 that will close this issue
hellodword added a commit to hellodword/bash-completion that referenced this issue Feb 5, 2024
long interface name will be truncated by ifconfig (issue scop#1089), prefer to use iproute2
hellodword added a commit to hellodword/bash-completion that referenced this issue Feb 5, 2024
long interface name will be truncated by ifconfig (issue scop#1089), prefer to use iproute2
hellodword added a commit to hellodword/bash-completion that referenced this issue Feb 8, 2024
long interface name may be truncated by ifconfig, prefer iproute2.
See also: scop#1089
hellodword added a commit to hellodword/bash-completion that referenced this issue Feb 8, 2024
long interface name may be truncated by ifconfig, prefer iproute2.
See also: scop#1089
hellodword added a commit to hellodword/bash-completion that referenced this issue Feb 8, 2024
long interface name may be truncated by ifconfig, prefer iproute2.
See also: scop#1089
hellodword added a commit to hellodword/bash-completion that referenced this issue Feb 8, 2024
long interface name may be truncated by ifconfig, prefer iproute2.
See also: scop#1089
hellodword added a commit to hellodword/bash-completion that referenced this issue Feb 8, 2024
long interface name may be truncated by ifconfig, prefer iproute2.
See also: scop#1089
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant