[pacman-dev] [PATCH] zsh: use pacman instead of parsing pacman.conf

Andrew Gregory andrew.gregory.8 at gmail.com
Thu Jan 26 15:19:11 UTC 2017


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


More information about the pacman-dev mailing list