summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-10-01 09:44:56 +0100
committerPeter Stephenson <pws@zsh.org>2015-10-01 09:44:56 +0100
commit8877783b2f98de67144f403e0146b6d201e98ba3 (patch)
treec8fe6c4d4fc6d7c93119c01cc300427655001ba3 /Completion
parent007f249a8e190306a9ef6bca2317e79004ace871 (diff)
parentbc2e73ba4c27a220a6f122cb7b9b5c6fa9996941 (diff)
downloadzsh-8877783b2f98de67144f403e0146b6d201e98ba3.tar.gz
zsh-8877783b2f98de67144f403e0146b6d201e98ba3.tar.xz
zsh-8877783b2f98de67144f403e0146b6d201e98ba3.zip
Merge branch 'master' of https://git.code.sf.net/p/zsh/code
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/Utility/_arguments45
1 files changed, 23 insertions, 22 deletions
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
index 1f35e8d43..87fb20e6b 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -8,15 +8,33 @@ local oldcontext="$curcontext" hasopts rawret optarg singopt alwopt
 local setnormarg start rest
 local -a match mbegin mend
 
+subopts=()
+singopt=()
+while [[ "$1" = -([AMO]*|[CRSWnsw]) ]]; 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;;
+  -W)  alwopt=arg; shift;;
+  -[Ss])  singopt+=( $1 ); shift;;
+  -[AM])  singopt+=( $1 $2 ); shift 2 ;;
+  -[AM]*) singopt+=( $1 ); shift ;;
+  esac
+done
+
+[[ $1 = ':' ]] && shift
+singopt+=( ':' )  # always end with ':' to indicate the end of options
+
+[[ "$PREFIX" = [-+] ]] && alwopt=arg
+
 long=$argv[(I)--]
 if (( long )); then
   local name tmp tmpargv
 
-  if [[ long -eq 1 ]]; then
-    tmpargv=()
-  else
-    tmpargv=( "${(@)argv[1,long-1]}" )
-  fi
+  tmpargv=( "${(@)argv[1,long-1]}" )  # optspec's before --, if any
 
   name=${~words[1]}
   [[ "$name" = [^/]*/* ]] && name="$PWD/$name"
@@ -290,23 +308,6 @@ if (( long )); then
   set -- "$tmpargv[@]" "${(@P)name}"
 fi
 
-subopts=()
-singopt=()
-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;;
-  esac
-done
-
-[[ "$PREFIX" = [-+] ]] && alwopt=arg
-
 zstyle -s ":completion:${curcontext}:options" auto-description autod
 
 if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then