summaryrefslogtreecommitdiff
path: root/completions/pkgadd
diff options
context:
space:
mode:
Diffstat (limited to 'completions/pkgadd')
-rw-r--r--completions/pkgadd34
1 files changed, 18 insertions, 16 deletions
diff --git a/completions/pkgadd b/completions/pkgadd
index 576b4114..3f5b6a11 100644
--- a/completions/pkgadd
+++ b/completions/pkgadd
@@ -2,7 +2,7 @@
#
# Copyright 2006 Yann Rouillard <yann@opencsw.org>
-_pkgadd ()
+_pkgadd()
{
local cur prev words cword
_init_completion -n : || return
@@ -12,10 +12,10 @@ _pkgadd ()
# available in this directory
local device=/var/spool/pkg
local i=$cword
- while [[ $((i--)) -gt 0 ]]; do
- case "${words[$i]}" in
+ while ((i-- > 0)); do
+ case "${words[i]}" in
-d)
- device="${words[$((i+1))]}"
+ device="${words[i + 1]}"
break
;;
esac
@@ -26,35 +26,37 @@ _pkgadd ()
_filedir pkg
_filedir -d
;;
- -a|-r|-V)
+ -a | -r | -V)
_filedir
;;
- -k|-s|-R)
+ -k | -s | -R)
_filedir -d
;;
- -P|-k|-x)
- ;;
+ -P | -x) ;;
+
*)
if [[ ${cur} == -* ]]; then
local opts="-a -A -d -k -n -M -P -r -R -s -v -V -x"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
else
local pkginst_list
if [[ -d $device ]]; then
+ local -a tmplist
for filedir in $(/bin/ls -1 $device); do
if [[ -d "$device/$filedir" ]] && [[ -f "$device/$filedir/pkginfo" ]]; then
- pkginst_list+=( ${pkginst_list[@]:-} "$filedir" )
+ tmplist+=(${tmplist[@]:-} "$filedir")
fi
done
- pkginst_list="${pkginst_list[@]}"
+ pkginst_list="${tmplist[*]}"
else
- pkginst_list=$(strings $(dequote $device) | \
- command grep "^PKG=" | sort -u | cut -d= -f2)
+ pkginst_list="$(strings "$(dequote $device)" |
+ command grep ^PKG= | sort -u | cut -d= -f2)"
+ fi
+ COMPREPLY=($(compgen -W "$pkginst_list" -- ${cur}))
fi
- COMPREPLY=( $(compgen -W "$pkginst_list" -- ${cur}) )
- fi
+ ;;
esac
} &&
-complete -F _pkgadd pkgadd
+ complete -F _pkgadd pkgadd
# ex: filetype=sh