-
Notifications
You must be signed in to change notification settings - Fork 392
WIP: Support more bind9 utilities #1321
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
e5ce915
9c16c37
5f92262
8c1eac9
8f3a039
2c119dc
5668561
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
# bash completion for nslookup -*- shell-script -*- | ||
# bind9 utilities completion | ||
|
||
_comp_cmd_rndc__list_commands() | ||
{ | ||
rndc 2>&1 | awk '/^ / {print $1}' | sort -u | ||
} | ||
|
||
_comp_cmd_rndc__list_parameters() | ||
{ | ||
local SUBCMD=$1 | ||
rndc 2>&1 | awk "/^ ${SUBCMD} / { print \$2 }" | ||
if [[ $cur == @* ]]; then | ||
_comp_compgen_known_hosts -- "$cur" | ||
return | ||
fi | ||
|
||
} | ||
|
||
# TODO: not used yet, useful for dnssec-signzone etc. | ||
_comp_cmd_named_checkconf__list_zones() | ||
{ | ||
named-checkconf -l | awk '{print $1}' | ||
} | ||
|
||
# TODO: named-rrchecker provides -T -C listings of supported query types. | ||
# should replace _comp_cmd_nslookup__queryclass, _comp_cmd_nslookup__querytype | ||
# when command is present. | ||
|
||
_comp_cmd_rndc() | ||
{ | ||
local cur prev words cword comp_args | ||
_comp_initialize -n = -- "$@" || return | ||
|
||
case $prev in | ||
-c|-k) | ||
_comp_compgen -a filedir | ||
return | ||
;; | ||
esac | ||
|
||
local REPLY | ||
_comp_count_args | ||
if [[ $cur == -* ]]; then | ||
_comp_compgen_usage | ||
return | ||
fi | ||
if ((REPLY == 1)); then | ||
_comp_compgen -- -W "$(_comp_cmd_rndc__list_commands)" | ||
fi | ||
if ((REPLY == 2)); then | ||
pemensik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_comp_compgen -- -W "$(_comp_cmd_rndc__list_parameters $prev)" | ||
fi | ||
} && complete -F _comp_cmd_rndc rndc | ||
|
||
_comp_cmd_dig__list_plusopts() | ||
{ | ||
local CMD=${1:-dig} # delv and mdig has similar style options | ||
$CMD -h 2>&1 | awk '/^\s+\+\[no\]/ { sub("+\\[no\\]", "", $1); sub("=##+$", "=", $1); sub("\\[=##+\\]", "", $1); print "+"$1, "+no"$1} /^\s+\+[^[]/ {sub("=##+", "=", $1); print $1}' | ||
akinomyoga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
_comp_cmd_dig() | ||
{ | ||
local cur prev words cword comp_args | ||
_comp_initialize -n = -- "$@" || return | ||
|
||
case $prev in | ||
-c) | ||
_comp_cmd_nslookup__queryclass | ||
return | ||
;; | ||
-t) | ||
_comp_cmd_nslookup__querytype | ||
return | ||
;; | ||
-q) | ||
_comp_compgen_known_hosts -- "$cur" | ||
return | ||
;; | ||
-k|-f) | ||
_comp_compgen -a filedir | ||
return | ||
;; | ||
-x|-b) | ||
_comp_compgen_ip_addresses -- "$cur" | ||
return | ||
;; | ||
esac | ||
|
||
if [[ $cur == @* ]]; then | ||
_comp_compgen_known_hosts -- "$cur" | ||
return | ||
fi | ||
if [[ $cur == -* ]]; then | ||
_comp_compgen_usage | ||
pemensik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
fi | ||
if [[ $cur == +* ]]; then | ||
_comp_compgen -- -W "$(_comp_cmd_dig__list_plusopts dig)" | ||
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace | ||
|
||
fi | ||
|
||
# TODO: dig is tricky. It can accept hostname, queryclass or querytype without any parameter. | ||
# Not sure how to autocomplete all of them. | ||
_comp_compgen_known_hosts -- "$cur" | ||
} && complete -F _comp_cmd_dig dig | ||
|
||
_comp_cmd_mdig() | ||
{ | ||
local cur prev words cword comp_args | ||
_comp_initialize -n = -- "$@" || return | ||
|
||
case $prev in | ||
-c) | ||
_comp_cmd_nslookup__queryclass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is defined in another file, which may not be loaded in the session. One needs to "export" the function by renaming This means that we need to modify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, yes. unless we would rely on named-rrchecker providing list of supported types. That does not come with common package containing utilities only. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. further more, it might be useful also for ldns But the question is, whether it would not make sense to move nslookup functions into the bind9 as a whole. They are after all bind9 utilities in normal circumstances. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We haven't been officially doing that when there are multiple implementations for a specific command name, but I think it would make sense. We should still keep our current implementation of |
||
return | ||
;; | ||
-t) | ||
_comp_cmd_nslookup__querytype | ||
return | ||
;; | ||
-q) | ||
_comp_compgen_known_hosts -- "$cur" | ||
return | ||
;; | ||
-f) | ||
_comp_compgen -a filedir | ||
akinomyoga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
;; | ||
-x|-b) | ||
_comp_compgen_ip_addresses -- "$cur" | ||
return | ||
;; | ||
esac | ||
|
||
if [[ $cur == -* ]]; then | ||
_comp_compgen_usage | ||
return | ||
fi | ||
if [[ $cur == @* ]]; then | ||
_comp_compgen_known_hosts -- "$cur" | ||
return | ||
fi | ||
|
||
if [[ $cur == +* ]]; then | ||
_comp_compgen -- -W "$(_comp_cmd_dig__list_plusopts mdig)" | ||
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace | ||
|
||
fi | ||
|
||
# TODO: dig is tricky. It can accept hostname, queryclass or querytype without any parameter. | ||
# Not sure how to autocomplete all of them. | ||
_comp_compgen_known_hosts -- "$cur" | ||
} && complete -F _comp_cmd_mdig mdig | ||
|
||
_comp_cmd_delv() | ||
{ | ||
local cur prev words cword comp_args | ||
_comp_initialize -n = -- "$@" || return | ||
|
||
case $prev in | ||
-c) | ||
_comp_cmd_nslookup__queryclass | ||
return | ||
;; | ||
-t) | ||
_comp_cmd_nslookup__querytype | ||
return | ||
;; | ||
-q) | ||
_comp_compgen_known_hosts -- "$cur" | ||
return | ||
;; | ||
-a) | ||
_comp_compgen -a filedir | ||
return | ||
;; | ||
-x|-b) | ||
_comp_compgen_ip_addresses -- "$cur" | ||
return | ||
;; | ||
esac | ||
|
||
if [[ $cur == -* ]]; then | ||
_comp_compgen_usage | ||
return | ||
fi | ||
if [[ $cur == @* ]]; then | ||
_comp_compgen_known_hosts -- "$cur" | ||
return | ||
fi | ||
|
||
if [[ $cur == +* ]]; then | ||
_comp_compgen -- -W "$(_comp_cmd_dig__list_plusopts delv)" | ||
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace | ||
|
||
fi | ||
|
||
# TODO: dig is tricky. It can accept hostname, queryclass or querytype without any parameter. | ||
# Not sure how to autocomplete all of them. | ||
_comp_compgen_known_hosts -- "$cur" | ||
} && complete -F _comp_cmd_delv delv | ||
|
||
# ex: filetype=sh |
Uh oh!
There was an error while loading. Please reload this page.