File tree Expand file tree Collapse file tree 12 files changed +32
-26
lines changed Expand file tree Collapse file tree 12 files changed +32
-26
lines changed Original file line number Diff line number Diff line change @@ -1523,7 +1523,7 @@ _comp_compgen_configured_interfaces()
15231523# -6: IPv6 addresses only
15241524# -a: All addresses
15251525#
1526- _comp_ip_addresses ()
1526+ _comp_compgen_ip_addresses ()
15271527{
15281528 local n
15291529 case ${1-} in
@@ -1532,13 +1532,19 @@ _comp_ip_addresses()
15321532 * ) n= ;;
15331533 esac
15341534 local PATH=$PATH :/sbin
1535- local addrs=$( {
1535+ local addrs
1536+ _comp_compgen -v addrs split -- " $( {
15361537 LC_ALL=C ifconfig -a || ip -c=never addr show || ip addr show
15371538 } 2> /dev/null |
15381539 command sed -e ' s/[[:space:]]addr:/ /' -ne \
1539- " s|.*inet${n} [[:space:]]\{1,\}\([^[:space:]/]*\).*|\1|p" )
1540- _comp_compgen -a -- -W " $addrs "
1541- [[ ! $n ]] || _comp_ltrim_colon_completions " $cur "
1540+ " s|.*inet${n} [[:space:]]\{1,\}\([^[:space:]/]*\).*|\1|p" ) " ||
1541+ return
1542+
1543+ if [[ ! $n ]]; then
1544+ _comp_compgen -R -- -W ' "${addrs[@]}"'
1545+ else
1546+ _comp_compgen_ltrim_colon " ${addrs[@]} "
1547+ fi
15421548}
15431549
15441550# This function completes on available kernels
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ _comp_deprecate_func 2.12 _signals _comp_compgen_signals
1616_comp_deprecate_func 2.12 _mac_addresses _comp_compgen_mac_addresses
1717_comp_deprecate_func 2.12 _available_interfaces _comp_available_interfaces
1818_comp_deprecate_func 2.12 _configured_interfaces _comp_compgen_configured_interfaces
19- _comp_deprecate_func 2.12 _ip_addresses _comp_ip_addresses
19+ _comp_deprecate_func 2.12 _ip_addresses _comp_compgen_ip_addresses
2020
2121# Backwards compatibility for compat completions that use have().
2222# @deprecated 1.90 should no longer be used; generally not needed with
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ _comp_cmd_arping()
1414 return
1515 ;;
1616 -* s)
17- _comp_ip_addresses
17+ _comp_compgen_ip_addresses
1818 return
1919 ;;
2020 esac
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ _comp_cmd_curl()
6767 return
6868 ;;
6969 --dns-ipv[46]-addr)
70- _comp_ip_addresses -" ${prev: 9: 1} "
70+ _comp_compgen_ip_addresses -" ${prev: 9: 1} "
7171 return
7272 ;;
7373 --dns-servers | --noproxy)
@@ -87,7 +87,7 @@ _comp_cmd_curl()
8787 --ftp-port | -${noargopts} P)
8888 _comp_available_interfaces -a
8989 _known_hosts_real -- " $cur "
90- _comp_ip_addresses -a
90+ _comp_compgen -a ip_addresses -a
9191 return
9292 ;;
9393 --ftp-method)
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ _comp_cmd_hddtemp()
1313 return
1414 ;;
1515 --listen | -${noargopts} l)
16- _comp_ip_addresses
16+ _comp_compgen_ip_addresses
1717 return
1818 ;;
1919 --unit | -${noargopts} u)
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ _comp_cmd_iperf()
3636 ;;
3737 --bind | -${noargopts} B)
3838 _comp_available_interfaces -a
39- _comp_ip_addresses -a
39+ _comp_compgen -a ip_addresses -a
4040 return
4141 ;;
4242 --bind-dev)
Original file line number Diff line number Diff line change @@ -42,11 +42,11 @@ _comp_cmd_links()
4242 return
4343 ;;
4444 -bind-address)
45- _comp_ip_addresses
45+ _comp_compgen_ip_addresses
4646 return
4747 ;;
4848 -bind-address-ipv6)
49- _comp_ip_addresses -6
49+ _comp_compgen_ip_addresses -6
5050 return
5151 ;;
5252 -async-dns | -download-utime | -aggressive-cache | -only-proxies | \
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ _comp_cmd_nc()
1111 ;;
1212 -* s)
1313 if [[ ${words[*]} == * -6* ]]; then
14- _comp_ip_addresses -6
14+ _comp_compgen_ip_addresses -6
1515 else
16- _comp_ip_addresses
16+ _comp_compgen_ip_addresses
1717 fi
1818 return
1919 ;;
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ _comp_cmd_ping()
4040 ;;
4141 -* S)
4242 # Socket sndbuf in Linux, source IP in FreeBSD
43- [[ $OSTYPE == * bsd* ]] && _comp_ip_addresses
43+ [[ $OSTYPE == * bsd* ]] && _comp_compgen_ip_addresses
4444 return
4545 ;;
4646 -* T)
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ _comp_cmd_ssh__suboption()
132132 _comp_compgen -- -W ' any inet inet6'
133133 ;;
134134 bindaddress)
135- _comp_ip_addresses
135+ _comp_compgen_ip_addresses
136136 ;;
137137 canonicalizehostname)
138138 _comp_compgen -- -W ' yes no always'
@@ -304,7 +304,7 @@ _comp_cmd_ssh()
304304 return
305305 ;;
306306 -* b)
307- _comp_ip_addresses
307+ _comp_compgen_ip_addresses
308308 return
309309 ;;
310310 -* c)
You can’t perform that action at this time.
0 commit comments