[pacman-dev] [PATCH] zsh: use pacman instead of parsing pacman.conf
This mimics the approach taken with the bash completion scripts and simply calls pacman -Sl to generate our list of unique repositories. This fixes cases where custom repos are defined in pacman.d/config snippets. --- scripts/completion/zsh_completion.in | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/completion/zsh_completion.in b/scripts/completion/zsh_completion.in index f74fa297..d7435f6d 100644 --- a/scripts/completion/zsh_completion.in +++ b/scripts/completion/zsh_completion.in @@ -316,8 +316,7 @@ _pacman_completions_all_packages() { typeset -U packages ${seq} _wanted packages expl "packages" compadd ${sep[@]} - "${(@)packages}" - repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options}) - typeset -U repositories + repositories=(${(u)${${(f)"$(pacman -Sl)"}%% *}}) _wanted repo_packages expl "repository/package" compadd -S "/" $repositories fi } @@ -348,9 +347,7 @@ _pacman_all_packages() { # provides completions for repository names _pacman_completions_repositories() { local -a cmd repositories - repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options}) - # Uniq the array - typeset -U repositories + repositories=(${(u)${${(f)"$(pacman -Sl)"}%% *}}) compadd "$@" -a repositories } -- 2.11.0
On 01/24/17 at 09:12pm, Earnestly via pacman-dev wrote:
This mimics the approach taken with the bash completion scripts and simply calls pacman -Sl to generate our list of unique repositories.
This fixes cases where custom repos are defined in pacman.d/config snippets. --- scripts/completion/zsh_completion.in | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
pacman -Sl is not suitable for parsing. This breaks on databases with spaces in their name.
diff --git a/scripts/completion/zsh_completion.in b/scripts/completion/zsh_completion.in index f74fa297..d7435f6d 100644 --- a/scripts/completion/zsh_completion.in +++ b/scripts/completion/zsh_completion.in @@ -316,8 +316,7 @@ _pacman_completions_all_packages() { typeset -U packages ${seq} _wanted packages expl "packages" compadd ${sep[@]} - "${(@)packages}"
- repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options}) - typeset -U repositories + repositories=(${(u)${${(f)"$(pacman -Sl)"}%% *}}) _wanted repo_packages expl "repository/package" compadd -S "/" $repositories fi } @@ -348,9 +347,7 @@ _pacman_all_packages() { # provides completions for repository names _pacman_completions_repositories() { local -a cmd repositories - repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options}) - # Uniq the array - typeset -U repositories + repositories=(${(u)${${(f)"$(pacman -Sl)"}%% *}}) compadd "$@" -a repositories }
-- 2.11.0
pacman -Sl is not suitable for parsing. This breaks on databases with spaces in their name.
I'm aware, and like the bash completion scripts this is not a complete solution as the tools needed to properly inspect pacman's configuration aren't readily available yet. (Excluding pacutils, which itself is not completely sufficient as it doesn't understand what a "repository" is beyond it being a section.) Ultimately both completion scripts will need a bit of reworking eventually. This patch is simply to tide it over until then.
On 01/26/17 at 03:50pm, Earnestly via pacman-dev wrote:
pacman -Sl is not suitable for parsing. This breaks on databases with spaces in their name.
I'm aware, and like the bash completion scripts this is not a complete solution as the tools needed to properly inspect pacman's configuration aren't readily available yet.
(Excluding pacutils, which itself is not completely sufficient as it doesn't understand what a "repository" is beyond it being a section.)
Hmmm? What's wrong with `pacconf --repo-list`? I promise I will eventually finish moving it over to pacman.
Ultimately both completion scripts will need a bit of reworking eventually. This patch is simply to tide it over until then.
Hmmm? What's wrong with `pacconf --repo-list`? I promise I will eventually finish moving it over to pacman.
Sigh, I was using pacini and didn't remember pacconf, sorry.
On 27/01/17 01:53, Andrew Gregory wrote:
Hmmm? What's wrong with `pacconf --repo-list`? I promise I will eventually finish moving it over to pacman.
Great! Because I am not accepting partial fixes to all the issues we currently have with scripts parsing pacman.conf. A
participants (3)
-
Allan McRae
-
Andrew Gregory
-
Earnestly