summaryrefslogtreecommitdiffstats
path: root/Completion/User/_combination
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-22 13:17:25 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-22 13:17:25 +0000
commit7d30343f32eb8df25d2b21b8b3e4f6d4386bd1cc (patch)
tree650d4a4dc3b7e3e5ef32e610831488099c1210bf /Completion/User/_combination
parentzsh-workers/7985 (diff)
downloadzsh-7d30343f32eb8df25d2b21b8b3e4f6d4386bd1cc.tar
zsh-7d30343f32eb8df25d2b21b8b3e4f6d4386bd1cc.tar.gz
zsh-7d30343f32eb8df25d2b21b8b3e4f6d4386bd1cc.tar.bz2
zsh-7d30343f32eb8df25d2b21b8b3e4f6d4386bd1cc.tar.lz
zsh-7d30343f32eb8df25d2b21b8b3e4f6d4386bd1cc.tar.xz
zsh-7d30343f32eb8df25d2b21b8b3e4f6d4386bd1cc.tar.zst
zsh-7d30343f32eb8df25d2b21b8b3e4f6d4386bd1cc.zip
zsh-workers/7989
Diffstat (limited to 'Completion/User/_combination')
-rw-r--r--Completion/User/_combination28
1 files changed, 19 insertions, 9 deletions
diff --git a/Completion/User/_combination b/Completion/User/_combination
index a122bd86f..631547311 100644
--- a/Completion/User/_combination
+++ b/Completion/User/_combination
@@ -1,9 +1,9 @@
#autoload
# Usage:
-# _combination [-s SEP] VARIABLE KEYi=PATi KEYj=PATj ... KEYm=PATm KEY EXPL...
+# _combination [-s S] V[:K1:...] Ki1[:Ni1]=Pi1 Ki2[:Ni2]=Pi2 ... Kim[:Nim]=Pim Kj[:Nj] EXPL...
#
-# VARIABLE must be formd as PREFIX_KEY1_..._KEYn.
+# It is assumed that V is formed as PRE_K1_..._Kn if `:K1:...' is not specified.
#
# Example: telnet
#
@@ -48,7 +48,7 @@
# the port argument if they are exist. And if it is failed, `_users' is
# called.
-local sep var keys pats key tmp
+local sep var keys pats key num tmp
if [[ "$1" = -s ]]; then
sep="$2"
@@ -60,21 +60,31 @@ fi
var=$1
shift
-keys=( "${(@s:_:)${var#*_}}" )
+if [[ $var = *:* ]]; then
+ keys=( ${(s/:/)var} )
+ shift keys
+ var="${var%%:*}"
+else
+ keys=( "${(@s:_:)${var#*_}}" )
+fi
pats=( "${(@)keys/*/*}" )
while [[ "$1" = *=* ]]; do
- pats[$keys[(i)${1%%\=*}]]="${1#*\=}"
+ tmp="${1%%\=*}"
+ key="${tmp%:*}"
+ num="${${tmp##*:}:-1}"
+ pats[$keys[(in:num:)$key]]="${1#*\=}"
shift
done
-key="$1"
+key="${1%:*}"
+num="${${1##*:}:-1}"
shift
if (( ${(P)+${var}} )); then
- eval "tmp=( \"\${(@M)${var}:#\${(j!$sep!)~pats}}\" )"
- if (( keys[(i)$key] != 1 )); then
- eval "tmp=( \${tmp#\${(j!${sep}!)~\${(@)\${(@)keys[2,(r)\$key]}/*/*}}$sep} )"
+ eval "tmp=( \"\${(@M)${var}:#\${(j($sep))~pats}}\" )"
+ if (( keys[(in:num:)$key] != 1 )); then
+ eval "tmp=( \${tmp#\${(j(${sep}))~\${(@)\${(@)keys[2,(rn:num:)\$key]}/*/*}}$sep} )"
fi
tmp=( ${tmp%%$sep*} )