aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gmail.com>2016-02-22 19:24:37 -0500
committerTim Harder <radhermit@gmail.com>2016-02-22 19:32:04 -0500
commit31732f921e2545da5085e4f57ca750ecd24b5748 (patch)
treedc0db9c230e798c418c012ab8b51c80f7faf6c7b
parentshell/zsh/pkgcore.zsh: remove obsolete -c option for _repos (diff)
downloadpkgcore-31732f921e2545da5085e4f57ca750ecd24b5748.tar.gz
pkgcore-31732f921e2545da5085e4f57ca750ecd24b5748.tar.bz2
pkgcore-31732f921e2545da5085e4f57ca750ecd24b5748.zip
shell/zsh/pkgcore.zsh: various formatting consistency
Mostly to be consistent and somewhat compatible with the forthcoming bash support and completions to minimize the annoyance of maintaining two implementations.
-rw-r--r--shell/zsh/pkgcore.zsh84
1 files changed, 42 insertions, 42 deletions
diff --git a/shell/zsh/pkgcore.zsh b/shell/zsh/pkgcore.zsh
index 85befe2de..120e5afd3 100644
--- a/shell/zsh/pkgcore.zsh
+++ b/shell/zsh/pkgcore.zsh
@@ -101,7 +101,7 @@ _repos() {
# skip comments and empty lines
[[ -z ${name} || ${name} == '#'* ]] && continue
if [[ (${name} == '['*']') && -z ${value} ]]; then
- repo_name=${name//(\[|\])}
+ repo_name=${name//[\[\]]}
[[ ${repo_name} != "DEFAULT" ]] && repos+=(${repo_name})
typeset -A ${repo_name}
else
@@ -110,29 +110,29 @@ _repos() {
done < ${file}
done
- if [[ -n $opts[(I)-v] ]]; then
+ if [[ -n ${opts[(I)-v]} ]]; then
section=${opts[-v]%%:*}
value=${opts[-v]##*:}
eval "output=\${${section}[${value}]}"
- elif [[ -n $opts[(I)-l] ]]; then
+ elif [[ -n ${opts[(I)-l]} ]]; then
# repo paths
output_type="repo paths"
- for repo in $repos; do
+ for repo in ${repos[@]}; do
eval "output+=(\${${repo}[location]})"
done
else
# repo names
output_type="repos"
- [[ -n $opts[(I)-e] ]] && repos+=( provided )
- [[ -n $opts[(I)-i] ]] && repos+=( vdb )
- [[ -n $opts[(I)-s] ]] && repos+=( repo-stack )
- output=(${repos})
+ [[ -n ${opts[(I)-e]} ]] && repos+=( provided )
+ [[ -n ${opts[(I)-i]} ]] && repos+=( vdb )
+ [[ -n ${opts[(I)-s]} ]] && repos+=( repo-stack )
+ output=(${repos[@]})
fi
- if [[ -n ${compstate} ]] && [[ -z $opts[(I)-p] ]]; then
+ if [[ -n ${compstate} ]] && [[ -z ${opts[(I)-p]} ]]; then
_describe -t repos ${output_type} output
else
- print $output
+ print ${output}
fi
}
@@ -147,8 +147,8 @@ _licenses() {
typeset -a licenses
- if [[ -n $opts[(I)-r] ]]; then
- repo=$opts[-r]
+ if [[ -n ${opts[(I)-r]} ]]; then
+ repo=${opts[-r]}
else
repo=$(_repos -p -v DEFAULT:main-repo)
fi
@@ -156,10 +156,10 @@ _licenses() {
repo_path=${$(_repos -p -v "${repo}:location")%/}
licenses=("${repo_path}"/licenses/*(.:t))
- if [[ -n ${compstate} ]] && [[ -z $opts[(I)-p] ]]; then
+ if [[ -n ${compstate} ]] && [[ -z ${opts[(I)-p]} ]]; then
_describe -t licenses 'licenses' licenses
else
- print $licenses
+ print ${licenses}
fi
}
@@ -178,36 +178,36 @@ _use() {
local desc
typeset -a use use_global use_local
- if [[ -n $opts[(I)-r] ]]; then
- repo=$opts[-r]
+ if [[ -n ${opts[(I)-r]} ]]; then
+ repo=${opts[-r]}
else
repo=$(_repos -p -v DEFAULT:main-repo)
fi
repo_path=${$(_repos -p -v "${repo}:location")%/}
- [[ -f $repo_path/profiles/use.desc ]] && use_global=(${(S)${${(f)"$(<${repo_path}/profiles/use.desc)"}:#\#*}/ - /:})
- [[ -f $repo_path/profiles/use.local.desc ]] && use_local=(${(S)${(S)${${(f)"$(<${repo_path}/profiles/use.local.desc)"}:#\#*}/*:/}/ - /:})
+ [[ -f ${repo_path}/profiles/use.desc ]] && use_global=(${(S)${${(f)"$(<${repo_path}/profiles/use.desc)"}:#\#*}/ - /:})
+ [[ -f ${repo_path}/profiles/use.local.desc ]] && use_local=(${(S)${(S)${${(f)"$(<${repo_path}/profiles/use.local.desc)"}:#\#*}/*:/}/ - /:})
- if [[ -z $opts[(I)-g] && -z $opts[(I)-l] ]]; then
+ if [[ -z ${opts[(I)-g]} && -z ${opts[(I)-l]} ]]; then
# both global and local use flags are shown by default
- use=( $use_global $use_local )
- elif [[ -n $opts[(I)-g] ]]; then
- use=$use_global
+ use=( ${use_global} ${use_local} )
+ elif [[ -n ${opts[(I)-g]} ]]; then
+ use=${use_global}
desc='global '
- elif [[ -n $opts[(I)-l] ]]; then
- use=$use_local
+ elif [[ -n ${opts[(I)-l]} ]]; then
+ use=${use_local}
desc='local '
fi
# strip use flag descriptions
- if [[ -n $opts[(I)-o] ]]; then
+ if [[ -n ${opts[(I)-o]} ]]; then
use=(${^use/:*/})
fi
- if [[ -n ${compstate} ]] && [[ -z $opts[(I)-p] ]]; then
+ if [[ -n ${compstate} ]] && [[ -z ${opts[(I)-p]} ]]; then
_describe -t use "${desc}use flag" use
else
- print $use
+ print ${use}
fi
}
@@ -222,19 +222,19 @@ _categories() {
typeset -a categories
- if [[ -n $opts[(I)-r] ]]; then
- repo=$opts[-r]
+ if [[ -n ${opts[(I)-r]} ]]; then
+ repo=${opts[-r]}
else
repo=$(_repos -p -v DEFAULT:main-repo)
fi
repo_path=${$(_repos -p -v "${repo}:location")%/}
- [[ -f $repo_path/profiles/categories ]] && categories=(${${(f)"$(<${repo_path}/profiles/categories)"}:#\#*})
+ [[ -f ${repo_path}/profiles/categories ]] && categories=(${${(f)"$(<${repo_path}/profiles/categories)"}:#\#*})
- if [[ -n ${compstate} ]] && [[ -z $opts[(I)-p] ]]; then
+ if [[ -n ${compstate} ]] && [[ -z ${opts[(I)-p]} ]]; then
_describe -t categories 'categories' categories
else
- print $categories
+ print ${categories}
fi
}
@@ -249,19 +249,19 @@ _arches() {
typeset -a arches
- if [[ -n $opts[(I)-r] ]]; then
- repo=$opts[-r]
+ if [[ -n ${opts[(I)-r] ]]}; then
+ repo=${opts[-r]}
else
repo=$(_repos -p -v DEFAULT:main-repo)
fi
repo_path=${$(_repos -p -v "${repo}:location")%/}
- [[ -f $repo_path/profiles/arch.list ]] && arches=(${${(f)"$(<${repo_path}/profiles/arch.list)"}:#\#*})
+ [[ -f ${repo_path}/profiles/arch.list ]] && arches=(${${(f)"$(<${repo_path}/profiles/arch.list)"}:#\#*})
- if [[ -n ${compstate} ]] && [[ -z $opts[(I)-p] ]]; then
+ if [[ -n ${compstate} ]] && [[ -z ${opts[(I)-p]} ]]; then
_describe -t arches 'arches' arches
else
- print $arches
+ print ${arches}
fi
}
@@ -278,8 +278,8 @@ _profiles() {
local file repo repo_path arch path pstatus
typeset -a profiles
- if [[ -n $opts[(I)-r] ]]; then
- repo=$opts[-r]
+ if [[ -n ${opts[(I)-r]} ]]; then
+ repo=${opts[-r]}
else
repo=$(_repos -p -v DEFAULT:main-repo)
fi
@@ -291,14 +291,14 @@ _profiles() {
while read -r arch path pstatus; do
# skip comments and empty lines
[[ -z ${arch} || ${arch} == '#'* ]] && continue
- [[ -n $opts[(I)-f] ]] && path=$repo_path/profiles/$path
+ [[ -n ${opts[(I)-f]} ]] && path=${repo_path}/profiles/${path}
profiles+=(${path})
done < ${file}
fi
- if [[ -n ${compstate} ]] && [[ -z $opts[(I)-p] ]]; then
+ if [[ -n ${compstate} ]] && [[ -z ${opts[(I)-p]} ]]; then
_describe -t profiles 'profiles' profiles $*
else
- print $profiles
+ print ${profiles}
fi
}