aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/openssl.bash
blob: b2bc1b7d6ac48d0654cb38497984a06da9c8c6c7 (plain) (blame)
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
# Some simple completion for openssl(1ssl)
_openssl() {

    # Only complete the first word: OpenSSL subcommands
    case $COMP_CWORD in
        1)
            while read -r subcmd ; do
                case $subcmd in
                    '') ;;
                    "${COMP_WORDS[COMP_CWORD]}"*)
                        COMPREPLY[${#COMPREPLY[@]}]=$subcmd
                        ;;
                esac
            done < <(
                for arg in \
                list-cipher-commands \
                list-standard-commands \
                list-message-digest-commands ; do
                    printf '%s\n' "$arg"
                    openssl "$arg"
                done
            )
            ;;
    esac
}

# bashdefault requires Bash >=3.0
if ((BASH_VERSINFO[0] >= 3)) ; then
    complete -F _openssl -o bashdefault -o default openssl
else
    complete -F _openssl -o default openssl
fi