Skip to content

Commit ec49676

Browse files
committed
refactor(ant,pkg-get,pkgutil,rpm,ssh): adjust towards current API
1 parent ec73841 commit ec49676

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

completions/ant

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# bash completion for ant and phing -*- shell-script -*-
22

3-
_ant_parse_targets()
3+
_comp_cmd_ant__targets()
44
{
55
local line basedir
66

@@ -9,7 +9,7 @@ _ant_parse_targets()
99
# parse buildfile for targets
1010
while read -rd '>' line; do
1111
if [[ $line =~ \<(target|extension-point)[[:space:]].*name=[\"\']([^\"\']+) ]]; then
12-
targets+=" ${BASH_REMATCH[2]}"
12+
ret+=("${BASH_REMATCH[2]}")
1313
fi
1414
done <"$1"
1515

@@ -19,7 +19,7 @@ _ant_parse_targets()
1919
local imported_buildfile
2020
imported_buildfile="${basedir}/${BASH_REMATCH[1]}"
2121
if [[ -f $imported_buildfile ]]; then
22-
_ant_parse_targets "$imported_buildfile"
22+
"$FUNCNAME" "$imported_buildfile"
2323
fi
2424
fi
2525
done <"$1"
@@ -87,12 +87,12 @@ _comp_cmd_ant()
8787
fi
8888
[[ ! -f $buildfile ]] && return
8989

90-
local targets
90+
local ret=()
9191

9292
# fill targets
93-
_ant_parse_targets "$buildfile"
93+
_comp_cmd_ant__targets "$buildfile"
9494

95-
COMPREPLY=($(compgen -W '$targets' -- "$cur"))
95+
COMPREPLY=($(compgen -W '"${ret[@]}"' -- "$cur"))
9696
fi
9797
} &&
9898
complete -F _comp_cmd_ant ant phing

completions/pkg-get

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
#
33
# Copyright 2006 Yann Rouillard <[email protected]>
44

5-
_pkg_get_get_catalog_file()
5+
_comp_cmd_pkg_get__catalog_file()
66
{
77
local url="$1"
8-
local catalog_file i conffile
8+
local i conffile
99

1010
for file in /etc/opt/csw/pkg-get.conf /opt/csw/etc/pkg-get.conf /etc/pkg-get.conf; do
1111
if [[ -f $file ]]; then
@@ -19,15 +19,13 @@ _pkg_get_get_catalog_file()
1919
url=$(awk -F= ' $1=="url" { print $2 }' "$conffile")
2020
fi
2121

22-
catalog_file="${url##*//}"
23-
catalog_file="${catalog_file%%/*}"
24-
catalog_file="/var/pkg-get/catalog-$catalog_file"
25-
26-
echo "$catalog_file"
22+
ret="${url##*//}"
23+
ret="${ret%%/*}"
24+
ret="/var/pkg-get/catalog-$ret"
2725
} &&
2826
_comp_cmd_pkg_get()
2927
{
30-
local cur prev file catalog_file url command=""
28+
local cur prev file url command=""
3129
COMPREPLY=()
3230
cur="${COMP_WORDS[COMP_CWORD]}"
3331
prev="${COMP_WORDS[COMP_CWORD - 1]}"
@@ -48,9 +46,10 @@ _pkg_get_get_catalog_file()
4846

4947
if [[ $command ]]; then
5048
if [[ $command == @(-[Ddi]|describe|download|install) ]]; then
51-
catalog_file=$(_pkg_get_get_catalog_file "$url")
52-
if [[ -f $catalog_file ]]; then
53-
local packages_list=$(awk '$0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "$catalog_file")
49+
local ret
50+
_comp_cmd_pkg_get__catalog_file "$url"
51+
if [[ -f $ret ]]; then
52+
local packages_list=$(awk '$0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "$ret")
5453
COMPREPLY=($(compgen -W "${packages_list}" -- "${cur}"))
5554
fi
5655
fi

completions/pkgutil

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# pkgutil completion -*- shell-script -*-
22
# Copyright 2006 Yann Rouillard <[email protected]>
33

4-
_pkgutil_url2catalog()
4+
_comp_cmd_pkgutil__url2catalog()
55
{
66
local filename="$1"
77

88
filename="${filename##*://}"
99
filename="${filename//\//_}"
1010
filename="/var/opt/csw/pkgutil/catalog.${filename}_$(uname -p)_$(uname -r)"
1111

12-
echo "$filename"
12+
ret=$filename
1313
}
1414

1515
_comp_cmd_pkgutil()
@@ -22,12 +22,12 @@ _comp_cmd_pkgutil()
2222
"/opt/csw/etc/pkgutil.conf" "/etc/opt/csw/pkgutil.conf")
2323
declare -a catalog_files=()
2424

25-
local i=$cword
25+
local i=$cword ret
2626
while ((i-- > 1)); do
2727
if [[ ${words[i]} == -@(t|-temp) ]]; then
2828
local url="${words[i + 1]}"
29-
local catalog=$(_pkgutil_url2catalog "$url")
30-
catalog_files=("$catalog")
29+
_comp_cmd_pkgutil__url2catalog "$url"
30+
catalog_files=("$ret")
3131
elif [[ ${words[i]} == --config ]]; then
3232
local ret
3333
_comp_dequote "${words[i + 1]}"
@@ -81,8 +81,8 @@ _comp_cmd_pkgutil()
8181
mirrors=$(awk -F= ' $1 ~ /^ *mirror *$/ { print $2 }' "${configuration_files[@]}")
8282
mirrors=${mirrors:-http://mirror.opencsw.org/opencsw/testing}
8383
for mirror_url in $mirrors; do
84-
local catalog=$(_pkgutil_url2catalog "$mirror_url")
85-
catalog_files=("${catalog_files[@]}" "$catalog")
84+
_comp_cmd_pkgutil__url2catalog "$mirror_url"
85+
catalog_files+=("$ret")
8686
done
8787

8888
if [[ $command == -@([dius]|-download|-install|-upgrade|-stream) ]]; then

completions/rpm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _comp_cmd_rpm__macros()
3636
-- "$cur"))
3737
}
3838

39-
_rpm_buildarchs()
39+
_comp_cmd_rpm__buildarchs()
4040
{
4141
COMPREPLY=($(compgen -W "$("${1:-rpm}" --showrc | command sed -ne \
4242
's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p')" \
@@ -255,7 +255,7 @@ _comp_cmd_rpmbuild()
255255
return
256256
;;
257257
--target)
258-
_rpm_buildarchs "$rpm"
258+
_comp_cmd_rpm__buildarchs "$rpm"
259259
return
260260
;;
261261
--eval | -${noargopts}E)

completions/ssh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ _comp_xfunc_ssh_suboption_check()
229229
_comp_deprecate_func _ssh_suboption_check _comp_xfunc_ssh_suboption_check
230230

231231
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
232-
_ssh_configfile()
232+
# @var[out] configfile Found configfile, if any
233+
_comp_cmd_ssh__configfile()
233234
{
234235
set -- "${words[@]}"
235236
while (($# > 0)); do
@@ -267,7 +268,7 @@ _comp_cmd_ssh()
267268
_comp_initialize -n : -- "$@" || return
268269

269270
local configfile
270-
_ssh_configfile
271+
_comp_cmd_ssh__configfile
271272

272273
_comp_xfunc_ssh_suboption_check "$1" && return
273274

@@ -371,7 +372,7 @@ _comp_cmd_sftp()
371372
_comp_initialize -- "$@" || return
372373

373374
local configfile
374-
_ssh_configfile
375+
_comp_cmd_ssh__configfile
375376

376377
_comp_xfunc_ssh_suboption_check && return
377378

@@ -511,7 +512,7 @@ _comp_cmd_scp()
511512
_comp_initialize -n : -- "$@" || return
512513

513514
local configfile
514-
_ssh_configfile
515+
_comp_cmd_ssh__configfile
515516

516517
_comp_xfunc_ssh_suboption_check && {
517518
COMPREPLY=("${COMPREPLY[@]/%/ }")

0 commit comments

Comments
 (0)