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
1 files changed,
3 insertions(+),
6 deletions(-)
jump to
M
contrib/pa-completion.bash
→
contrib/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