From 6c09f2a45c5541e9c207d14fc7aa21a4a0066bde Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 03:03:19 +0200 Subject: Merging upstream version 1:2.12.0. Signed-off-by: Daniel Baumann --- completions/pkg-get | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'completions/pkg-get') diff --git a/completions/pkg-get b/completions/pkg-get index 72bd0a0..a8ec1a8 100644 --- a/completions/pkg-get +++ b/completions/pkg-get @@ -2,10 +2,10 @@ # # Copyright 2006 Yann Rouillard -_pkg_get_get_catalog_file() +_comp_cmd_pkg_get__catalog_file() { local url="$1" - local catalog_file i conffile + local i conffile for file in /etc/opt/csw/pkg-get.conf /opt/csw/etc/pkg-get.conf /etc/pkg-get.conf; do if [[ -f $file ]]; then @@ -15,19 +15,17 @@ _pkg_get_get_catalog_file() done conffile="${conffile:-/opt/csw/etc/pkg-get.conf}" - if [[ -z $url ]]; then - url=$(awk -F= ' $1=="url" { print $2 }' $conffile) + if [[ ! $url ]]; then + url=$(_comp_awk -F = ' $1=="url" { print $2 }' "$conffile") fi - catalog_file="${url##*//}" - catalog_file="${catalog_file%%/*}" - catalog_file="/var/pkg-get/catalog-$catalog_file" - - echo "$catalog_file" + REPLY="${url##*//}" + REPLY="${REPLY%%/*}" + REPLY="/var/pkg-get/catalog-$REPLY" } && - _pkg_get() + _comp_cmd_pkg_get() { - local cur prev file catalog_file url command + local cur prev file url command="" COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD - 1]}" @@ -46,27 +44,29 @@ _pkg_get_get_catalog_file() fi done - if [[ -v command ]]; then + if [[ $command ]]; then if [[ $command == @(-[Ddi]|describe|download|install) ]]; then - catalog_file=$(_pkg_get_get_catalog_file "$url") - if [[ -f $catalog_file ]]; then - local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' $catalog_file) - COMPREPLY=($(compgen -W "${packages_list}" -- ${cur})) + local REPLY + _comp_cmd_pkg_get__catalog_file "$url" + if [[ -f $REPLY ]]; then + local packages_list=$(_comp_awk '$0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "$REPLY") + _comp_compgen -- -W "${packages_list}" fi fi return fi if [[ ${cur} == -* ]]; then - local opts="-c -d -D -f -i -l -s -S -u -U -v" - COMPREPLY=($(compgen -W "${opts}" -- ${cur})) + local -a opts=(-c -d -D -f -i -l -s -S -u -U -v) + _comp_compgen -- -W '"${opts[@]}"' return fi - local commands="available describe download install list \ - updatecatalog upgrade" - COMPREPLY=($(compgen -W "${commands}" -- ${cur})) + local -a commands=( + available describe download install list updatecatalog upgrade + ) + _comp_compgen -- -W '"${commands[@]}"' } && - complete -F _pkg_get pkg-get + complete -F _comp_cmd_pkg_get pkg-get # ex: filetype=sh -- cgit v1.2.3