summaryrefslogtreecommitdiff
path: root/completions/slapt-src
diff options
context:
space:
mode:
Diffstat (limited to 'completions/slapt-src')
-rw-r--r--completions/slapt-src35
1 files changed, 18 insertions, 17 deletions
diff --git a/completions/slapt-src b/completions/slapt-src
index 64458bab..1e3828c0 100644
--- a/completions/slapt-src
+++ b/completions/slapt-src
@@ -6,11 +6,11 @@ _slapt_src()
_init_completion -s -n : || return
case "$prev" in
- --config|-c)
+ --config | -c)
_filedir
return
;;
- --search|-s|--postprocess|-p)
+ --search | -s | --postprocess | -p)
# argument required but no completions available
return
;;
@@ -18,15 +18,17 @@ _slapt_src()
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
- [[ $COMPREPLY ]] && return
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ if [[ ${COMPREPLY-} ]]; then
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ return
+ fi
fi
local i t
# search for last action (-i|-w|-b|-f)
- for (( i=${#words[@]}-1; i>0; i-- )); do
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@([iwfb]|-install|-show|-build|-fetch) ]]; then
t="all"
break
@@ -38,9 +40,9 @@ _slapt_src()
local config="/etc/slapt-get/slapt-srcrc" # default config location
# search for config
- for (( i=${#words[@]}-1; i>0; i-- )); do
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@(c|-config) ]]; then
- config="${words[i+1]}"
+ config="${words[i + 1]}"
__expand_tilde_by_ref config
break
fi
@@ -49,19 +51,18 @@ _slapt_src()
break
fi
done
- [[ -r "$config" ]] || return
+ [[ -r $config ]] || return
- if [[ "$cur" == *:* ]]; then
+ if [[ $cur == *:* ]]; then
local name=${cur%:*}
- local version=${cur##*:}
- COMPREPLY=( $(LC_ALL=C "$1" --config "$config" --search "^$name" \
+ COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$name" \
2>/dev/null | LC_ALL=C command sed -ne \
- "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}") )
+ "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}"))
else
- COMPREPLY=( $(LC_ALL=C "$1" --config "$config" --search "^$cur" \
- 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") )
+ COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$cur" \
+ 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}"))
fi
} &&
-complete -F _slapt_src slapt-src
+ complete -F _slapt_src slapt-src
# ex: filetype=sh