[pacman-dev] [PATCH] zsh completion: get installed packages with pacman -Qq
Currently _pacman_completions_installed_packages() globs the directory @localstatedir@/lib/pacman/local/, this does not respect changes to DBPath in /etc/pacman.conf, which cause completion to stop working. Instead of globbing $(pacman -Qq) can be called to get a list of installed packages correctly. Signed-off-by: Roma Kovalev <roma.kvl@gmail.com> --- contrib/zsh_completion.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index 1cae1de..0eae5e9 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -285,9 +285,8 @@ _pacman_completions_installed_groups() { # provides completions for installed packages _pacman_completions_installed_packages() { - local -a cmd packages packages_long - packages_long=(@localstatedir@/lib/pacman/local/*(/)) - packages=( ${${packages_long#@localstatedir@/lib/pacman/local/}%-*-*} ) + local -a packages + packages=( $(pacman -Qq) ) compadd "$@" -a packages } -- 2.2.2
On 08/02/15 09:30, Roma Kovalev wrote:
Currently _pacman_completions_installed_packages() globs the directory @localstatedir@/lib/pacman/local/, this does not respect changes to DBPath in /etc/pacman.conf, which cause completion to stop working. Instead of globbing $(pacman -Qq) can be called to get a list of installed packages correctly.
Signed-off-by: Roma Kovalev <roma.kvl@gmail.com> ---
Ack - I assume this was originally done for speed. But changing this is also robust for potential local database format changes. A
contrib/zsh_completion.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index 1cae1de..0eae5e9 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -285,9 +285,8 @@ _pacman_completions_installed_groups() {
# provides completions for installed packages _pacman_completions_installed_packages() { - local -a cmd packages packages_long - packages_long=(@localstatedir@/lib/pacman/local/*(/)) - packages=( ${${packages_long#@localstatedir@/lib/pacman/local/}%-*-*} ) + local -a packages + packages=( $(pacman -Qq) ) compadd "$@" -a packages }
On 02/08/15 at 02:30am, Roma Kovalev wrote:
Currently _pacman_completions_installed_packages() globs the directory @localstatedir@/lib/pacman/local/, this does not respect changes to DBPath in /etc/pacman.conf, which cause completion to stop working. Instead of globbing $(pacman -Qq) can be called to get a list of installed packages correctly.
Signed-off-by: Roma Kovalev <roma.kvl@gmail.com> --- contrib/zsh_completion.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index 1cae1de..0eae5e9 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -285,9 +285,8 @@ _pacman_completions_installed_groups() {
# provides completions for installed packages _pacman_completions_installed_packages() { - local -a cmd packages packages_long - packages_long=(@localstatedir@/lib/pacman/local/*(/)) - packages=( ${${packages_long#@localstatedir@/lib/pacman/local/}%-*-*} ) + local -a packages + packages=( $(pacman -Qq) )
This should use _pacman_get_command so that --root and --config options will be taken into account. _pacman_get_command should also be updated to take --dbpath into account.
compadd "$@" -a packages }
-- 2.2.2
participants (3)
-
Allan McRae
-
Andrew Gregory
-
Roma Kovalev