blob: b04b03a4904412c9b8c079ed91715ceb0e9a3afc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# bash completion for nslookup -*- shell-script -*-
_comp_cmd_nslookup__queryclass()
{
_comp_compgen -a -- -W 'IN CH HS ANY'
}
_comp_cmd_nslookup__querytype()
{
# https://en.wikipedia.org/wiki/List_of_DNS_record_types
# Resource records
local -a types=(
A AAAA AFSDB APL CAA CDNSKEY CDS CERT CNAME CSYNC DHCID DLV DNAME
DNSKEY DS EUI48 EUI64 HINFO HIP IPSECKEY KEY KX LOC MX NAPTR NS NSEC
NSEC3 NSEC3PARAM OPENPGPKEY PTR RRSIG RP SIG SMIMEA SOA SRV SSHFP TA
TKEY TLSA TSIG TXT URI ZONEMD SVCB HTTPS
)
# Other types/pseudo record types
types+=(AXFR IXFR OPT)
# Selected obsolete record types
types+=(SPF)
_comp_compgen -a -- -W '"${types[@]}"'
}
_comp_cmd_nslookup()
{
local cur prev words cword comp_args
_comp_initialize -n = -- "$@" || return
case $cur in
-class=* | -cl=*)
cur=${cur#*=}
_comp_cmd_nslookup__queryclass
return
;;
-querytype=* | -type=* | -q=* | -ty=*)
cur=${cur#*=}
_comp_cmd_nslookup__querytype
return
;;
-?*=*)
return
;;
esac
if [[ $cur == -* ]]; then
_comp_compgen -- -W '-all -class= -debug -nodebug -d2 -nod2 -domain=
-search -nosearch -port= -querytype= -recurse -norecurse -retry=
-timeout= -vc -novc -fail -nofail'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
local REPLY
_comp_count_args
if ((REPLY <= 2)); then
_comp_compgen_known_hosts -- "$cur"
[[ $REPLY -eq 1 && $cur == @(|-) ]] && COMPREPLY+=(-)
fi
} &&
complete -F _comp_cmd_nslookup nslookup
_comp_cmd_host()
{
local cur prev words cword comp_args
_comp_initialize -- "$@" || return
case $prev in
-c)
_comp_cmd_nslookup__queryclass
return
;;
-t)
_comp_cmd_nslookup__querytype
return
;;
-m)
_comp_compgen -- -W 'trace record usage'
return
;;
-N | -R | -W)
return
;;
esac
if [[ $cur == -* ]]; then
_comp_compgen_usage
return
fi
local REPLY
_comp_count_args -a "-*[ctmNRW]"
if ((REPLY == 1)); then
_comp_compgen_known_hosts -- "$cur"
elif ((REPLY == 2)); then
local ipvx
[[ ${words[*]} =~ \ -[^\ ]*([46]) ]] && ipvx=-${BASH_REMATCH[1]}
# shellcheck disable=SC2086
_comp_compgen_known_hosts ${ipvx-} -- "$cur"
fi
} &&
complete -F _comp_cmd_host host
# ex: filetype=sh
|