diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-05-18 10:48:31 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-05-18 10:48:31 +0000 |
commit | ca670d4d27953588909d4b682eae5d7757bcf512 (patch) | |
tree | 0d08d04ad83287c0bd7371570da541ae77841b60 /Completion | |
parent | 781a5bd4b1ac91e18bd58470030fac8f15d6a432 (diff) | |
download | zsh-ca670d4d27953588909d4b682eae5d7757bcf512.tar.gz zsh-ca670d4d27953588909d4b682eae5d7757bcf512.tar.xz zsh-ca670d4d27953588909d4b682eae5d7757bcf512.zip |
allow _main_complete to call an arbitrary command given as arguments (11459)
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Core/_main_complete | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index 03fb15f31..a67e57db6 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -20,7 +20,7 @@ setopt localoptions nullglob rcexpandparam extendedglob unsetopt markdirs globsubst shwordsplit nounset ksharrays exec </dev/null # ZLE closes stdin, which can cause errors -local func funcs ret=1 tmp _compskip format nm \ +local func funcs ret=1 tmp _compskip format nm call \ _completers _completer _completer_num curtag _comp_force_list \ _matchers _matcher _matcher_num _comp_tags _comp_mesg \ context state line opt_args val_args curcontext="$curcontext" \ @@ -84,7 +84,16 @@ fi # Get the names of the completers to use in the positional parameters. if (( $# )); then - _completers=( "$@" ) + if [[ "$1" = - ]]; then + if [[ $# -lt 3 ]]; then + _completers=() + else + _completers=( "$2" ) + call=yes + fi + else + _completers=( "$@" ) + fi else zstyle -a ":completion:${curcontext}:" completer _completers || _completers=( _complete _ignored ) @@ -104,7 +113,9 @@ done for tmp in "$_completers[@]"; do - if [[ "$tmp" = *:-* ]]; then + if [[ -n "$call" ]]; then + _completer="${tmp}" + elif [[ "$tmp" = *:-* ]]; then _completer="${${tmp%:*}[2,-1]//_/-}${tmp#*:}" tmp="${tmp%:*}" elif [[ $tmp = *:* ]]; then @@ -120,7 +131,12 @@ for tmp in "$_completers[@]"; do _matcher_num=1 for _matcher in "$_matchers[@]"; do - if "$tmp"; then + if [[ -n "$call" ]]; then + if "${(@)argv[3,-1]}"; then + ret=0 + break 2 + fi + elif "$tmp"; then ret=0 break 2 fi |