small pixel drawing of a pufferfish pa

speed up bash completion

by using param transformation instead of printf for escaping
arĉi arcxi@dismail.de
Wed, 19 Jun 2024 05:34:56 +0200
commit

68d278e32a49d61a11acec272da67c9a53eea712

parent

925265d8c06f762223ba1748e4dae2e0f47b4207

1 files changed, 3 insertions(+), 6 deletions(-)

jump to
M contrib/pa-completion.bashcontrib/pa-completion.bash

@@ -1,16 +1,13 @@

_pa() { - if [[ $COMP_CWORD -ne 2 ]]; then return; fi - case "${COMP_WORDS[1]}" in [des]*) + [[ $COMP_CWORD -eq 2 ]] && case "${COMP_WORDS[1]}" in [des]*) names=() # Escape all password names so compgen doesn't break. - while read -r name; do - names+=("$(printf "%q\n" "$name")") - done < <(pa list) + while read -r name; do names+=("${name@Q}"); done < <(pa list) mapfile -t COMPREPLY < <(compgen -W "${names[*]}" -- "${COMP_WORDS[2]}") ;; esac } -complete -o filenames -o nospace -F _pa pa +complete -o filenames -F _pa pa