From 966ff3a185ba150625cd14022392d310cf9c1649 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 27 Sep 2006 16:53:58 +0000 Subject: 22780: add _arguments/comparguments -n to set index of first non-option arg --- Completion/Base/Utility/_arguments | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Completion/Base/Utility') diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments index 05a287a5f..a87486168 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -5,6 +5,7 @@ local long cmd="$words[1]" descr mesg subopts opt usecc autod local oldcontext="$curcontext" hasopts rawret optarg singopt alwopt +local setnormarg long=$argv[(I)--] if (( long )); then @@ -189,12 +190,13 @@ fi subopts=() singopt=() -while [[ "$1" = -(O*|[CRWsw]) ]]; do +while [[ "$1" = -(O*|[CRWnsw]) ]]; do case "$1" in -C) usecc=yes; shift ;; -O) subopts=( "${(@P)2}" ); shift 2 ;; -O*) subopts=( "${(@P)${1[3,-1]}}" ); shift ;; -R) rawret=yes; shift;; + -n) setnormarg=yes; NORMARG=-1; shift;; -w) optarg=yes; shift;; -s) singopt=(-s); shift;; -W) alwopt=arg; shift;; @@ -251,6 +253,10 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then descr="$descrs[anum]" subc="$subcs[anum++]" + if [[ $subc = argument* && -n $setnormarg ]]; then + comparguments -n NORMARG + fi + if [[ -n "$matched" ]] || _requested "$subc"; then curcontext="${oldcontext%:*}:$subc" -- cgit 1.4.1