[PATCH 1/1] bash completion without relying on /etc/bash-completion.d

Jason A. Donenfeld Jason at zx2c4.com
Sat Feb 2 03:17:52 CET 2019


On Wed, Jan 30, 2019 at 11:05 PM Lars Flitter
<password-store at larsflitter.de> wrote:
>
> +SYSTEM_EXTENSION_DIR=""
> +PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
> +EXTENSIONS="${PASSWORD_STORE_EXTENSIONS_DIR:-$PREFIX/.extensions}"
> +
> +

Extra new line.

> +_pass_extension_commands() {
> +       if [[ -d $SYSTEM_EXTENSION_DIR ]]; then
> +               for file in $SYSTEM_EXTENSION_DIR/*.bash; do

file leaks into the global scope (needs local specifier) and
$SYSTEM_EXTENSION_DIR should be quoted.


> +                       if [[ -f $file ]]; then
> +                               file=${file##*/};

Missing quotes.

> +                               echo "${file%.bash}";
> +                       fi
> +               done
> +       fi
> +
> +       if [[ $PASSWORD_STORE_ENABLE_EXTENSIONS == true ]]; then
> +               for file in $EXTENSIONS/*.bash; do

Same as above.

> +                       if [[ -f $file ]]; then
> +                               file=${file##*/};
Same as above.
> +                               echo "${file%.bash}";
> +                       fi
> +                done
> +       fi
> +}
>
> +# COMPREPLY+=($(compgen -W "-o --option" -- ${cur}))

Does cur need quotes? What's the norm for this file in that idiom?

> +               completion="$user_extension_completion"

Leaks into global scope.

> +       elif [[ -n $system_extension_commpletion && -f $system_extension_commpletion ]]; then
> +               completion="$system_extension_commpletion"
Leaks into global scope.

> +       source $completion

Needs quotes. But instead of doing it this way, can't you just put the
scope on each of the lines above and get rid of the variable?

> +                       *)
> +                               _source_extension_completion ${COMP_WORDS[1]}
> +                               ;;

Missing quotes?


More information about the Password-Store mailing list