secret/argz/argz.sh
Adrien Gallouët 9a921c5752 Support completion on bash 3.x
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-04-24 11:20:18 +00:00

17 lines
497 B
Bash

_argz_reply() {
while IFS='' read -r line; do COMPREPLY+=("$line"); done
}
_argz() {
local last opts
last="${COMP_WORDS[COMP_CWORD]}"
COMP_WORDS[COMP_CWORD]="help"
opts="$("${COMP_WORDS[@]}" 2>/dev/null | awk '{print $1}' )"
case "$opts" in
'') ;;
CMD) _argz_reply < <(compgen -A command -- "$last") ;;
DIR) _argz_reply < <(compgen -A dir -- "$last") ;;
FILE) _argz_reply < <(compgen -A file -- "$last") ;;
*) _argz_reply < <(compgen -W "$opts" -- "$last") ;;
esac
}