From 799e0512859026c4ffe6379e31cc0ded98b4c274 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Wed, 26 Jun 2013 23:21:17 +0200 Subject: [PATCH] Fix bash completion * Add files to the possibilities (needed at least for pastoob). For now show them only if nothing else matches. * Remove useless "$have" test that failed every time * Forget fake "hash" after running * Simpler code overall --- tools/weboob_bash_completion | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tools/weboob_bash_completion b/tools/weboob_bash_completion index a22d971f..8ffe3c1b 100644 --- a/tools/weboob_bash_completion +++ b/tools/weboob_bash_completion @@ -22,26 +22,20 @@ # This script can be distributed under the same license as the # weboob or bash packages. -hash weboob-config 2>/dev/null && _weboob() { - local cur words + local cur args COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} - words="$(${COMP_WORDS[0]} --shell-completion)" - - case ${COMP_WORDS[1]} in - *) - COMPREPLY=( $( compgen -W "$words" | grep "^$cur" ) ) - ;; - esac - - return 0 + args="$(${COMP_WORDS[0]} --shell-completion)" + COMPREPLY=( $(compgen -o default -W "${args}" -- "$cur" ) ) } -[ "$have" ] || return + +hash weboob-config 2>/dev/null && weboob_applications=$(weboob-config applications) +hash -d weboob-config for application in $weboob_applications do complete -F _weboob $application