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()
1523
1523
# -6: IPv6 addresses only
1524
1524
# -a: All addresses
1525
1525
#
1526
- _comp_ip_addresses ()
1526
+ _comp_compgen_ip_addresses ()
1527
1527
{
1528
1528
local n
1529
1529
case ${1-} in
@@ -1532,13 +1532,19 @@ _comp_ip_addresses()
1532
1532
* ) n= ;;
1533
1533
esac
1534
1534
local PATH=$PATH :/sbin
1535
- local addrs=$( {
1535
+ local addrs
1536
+ _comp_compgen -v addrs split -- " $( {
1536
1537
LC_ALL=C ifconfig -a || ip -c=never addr show || ip addr show
1537
1538
} 2> /dev/null |
1538
1539
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
1542
1548
}
1543
1549
1544
1550
# 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
16
16
_comp_deprecate_func 2.12 _mac_addresses _comp_compgen_mac_addresses
17
17
_comp_deprecate_func 2.12 _available_interfaces _comp_available_interfaces
18
18
_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
20
20
21
21
# Backwards compatibility for compat completions that use have().
22
22
# @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()
14
14
return
15
15
;;
16
16
-* s)
17
- _comp_ip_addresses
17
+ _comp_compgen_ip_addresses
18
18
return
19
19
;;
20
20
esac
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ _comp_cmd_curl()
67
67
return
68
68
;;
69
69
--dns-ipv[46]-addr)
70
- _comp_ip_addresses -" ${prev: 9: 1} "
70
+ _comp_compgen_ip_addresses -" ${prev: 9: 1} "
71
71
return
72
72
;;
73
73
--dns-servers | --noproxy)
@@ -87,7 +87,7 @@ _comp_cmd_curl()
87
87
--ftp-port | -${noargopts} P)
88
88
_comp_available_interfaces -a
89
89
_known_hosts_real -- " $cur "
90
- _comp_ip_addresses -a
90
+ _comp_compgen -a ip_addresses -a
91
91
return
92
92
;;
93
93
--ftp-method)
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ _comp_cmd_hddtemp()
13
13
return
14
14
;;
15
15
--listen | -${noargopts} l)
16
- _comp_ip_addresses
16
+ _comp_compgen_ip_addresses
17
17
return
18
18
;;
19
19
--unit | -${noargopts} u)
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ _comp_cmd_iperf()
36
36
;;
37
37
--bind | -${noargopts} B)
38
38
_comp_available_interfaces -a
39
- _comp_ip_addresses -a
39
+ _comp_compgen -a ip_addresses -a
40
40
return
41
41
;;
42
42
--bind-dev)
Original file line number Diff line number Diff line change @@ -42,11 +42,11 @@ _comp_cmd_links()
42
42
return
43
43
;;
44
44
-bind-address)
45
- _comp_ip_addresses
45
+ _comp_compgen_ip_addresses
46
46
return
47
47
;;
48
48
-bind-address-ipv6)
49
- _comp_ip_addresses -6
49
+ _comp_compgen_ip_addresses -6
50
50
return
51
51
;;
52
52
-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()
11
11
;;
12
12
-* s)
13
13
if [[ ${words[*]} == * -6* ]]; then
14
- _comp_ip_addresses -6
14
+ _comp_compgen_ip_addresses -6
15
15
else
16
- _comp_ip_addresses
16
+ _comp_compgen_ip_addresses
17
17
fi
18
18
return
19
19
;;
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ _comp_cmd_ping()
40
40
;;
41
41
-* S)
42
42
# Socket sndbuf in Linux, source IP in FreeBSD
43
- [[ $OSTYPE == * bsd* ]] && _comp_ip_addresses
43
+ [[ $OSTYPE == * bsd* ]] && _comp_compgen_ip_addresses
44
44
return
45
45
;;
46
46
-* T)
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ _comp_cmd_ssh__suboption()
132
132
_comp_compgen -- -W ' any inet inet6'
133
133
;;
134
134
bindaddress)
135
- _comp_ip_addresses
135
+ _comp_compgen_ip_addresses
136
136
;;
137
137
canonicalizehostname)
138
138
_comp_compgen -- -W ' yes no always'
@@ -304,7 +304,7 @@ _comp_cmd_ssh()
304
304
return
305
305
;;
306
306
-* b)
307
- _comp_ip_addresses
307
+ _comp_compgen_ip_addresses
308
308
return
309
309
;;
310
310
-* c)
You can’t perform that action at this time.
0 commit comments