aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/gpg.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bash_completion.d/gpg.bash')
-rw-r--r--bash/bash_completion.d/gpg.bash21
1 files changed, 12 insertions, 9 deletions
diff --git a/bash/bash_completion.d/gpg.bash b/bash/bash_completion.d/gpg.bash
index bfa2d1a9..c6f92676 100644
--- a/bash/bash_completion.d/gpg.bash
+++ b/bash/bash_completion.d/gpg.bash
@@ -1,7 +1,7 @@
# Completion for gpg(1) with long options
_gpg() {
- # Bail if no gpg(1)
+ # Needs gpg(1)
hash gpg 2>/dev/null || return
# Bail if not completing an option
@@ -11,13 +11,16 @@ _gpg() {
esac
# Generate completion reply from gpg(1) options
- local option
- while read -r option ; do
- case $option in
- "$2"*)
- COMPREPLY[${#COMPREPLY[@]}]=$option
- ;;
- esac
- done < <(gpg --dump-options 2>/dev/null)
+ local ci comp
+ while read -r comp ; do
+ COMPREPLY[ci++]=$comp
+ done < <(
+ gpg --dump-options 2>/dev/null |
+ while read -r option ; do
+ case $option in
+ ("$2"*) printf '%s\n' "$option" ;;
+ esac
+ done
+ )
}
complete -F _gpg -o bashdefault -o default gpg