diff options
37 files changed, 98 insertions, 52 deletions
@@ -1,5 +1,30 @@ 2026-06-08 dana <dana@dana.is> + * 54659: Completion/Zsh/Command/_alias, + Completion/Zsh/Command/_bindkey, + Completion/Zsh/Command/_command, + Completion/Zsh/Command/_compadd, Completion/Zsh/Command/_dirs, + Completion/Zsh/Command/_disable, + Completion/Zsh/Command/_emulate, + Completion/Zsh/Command/_enable, Completion/Zsh/Command/_exec, + Completion/Zsh/Command/_fc, Completion/Zsh/Command/_hash, + Completion/Zsh/Command/_jobs_builtin, + Completion/Zsh/Command/_kill, Completion/Zsh/Command/_print, + Completion/Zsh/Command/_prompt, Completion/Zsh/Command/_read, + Completion/Zsh/Command/_set, Completion/Zsh/Command/_strftime, + Completion/Zsh/Command/_tcpsys, + Completion/Zsh/Command/_typeset, + Completion/Zsh/Command/_unhash, Completion/Zsh/Command/_vared, + Completion/Zsh/Command/_which, Completion/Zsh/Command/_zattr, + Completion/Zsh/Command/_zcompile, Completion/Zsh/Command/_zed, + Completion/Zsh/Command/_zle, Completion/Zsh/Command/_zmodload, + Completion/Zsh/Command/_zmv, + Completion/Zsh/Command/_zparseopts, + Completion/Zsh/Command/_zpty, Completion/Zsh/Command/_zsocket, + Completion/Zsh/Function/__arguments, Doc/Zsh/compsys.yo, + Src/Zle/computil.c, Test/Y03arguments.ztst: comparguments: + support zsh-style '-' terminator with -S -S + * unposted: Functions/Misc/zgetopt: try funcstack for function name diff --git a/Completion/Zsh/Command/_alias b/Completion/Zsh/Command/_alias index 617627cbe..86e9a88f0 100644 --- a/Completion/Zsh/Command/_alias +++ b/Completion/Zsh/Command/_alias @@ -3,7 +3,7 @@ local curcontext="$curcontext" state line expl type suf typeset -A opt_args -_arguments -C -s -A "-*" -S \ +_arguments -C -s -A "-*" -S -S : \ '(-r +r -s +s)-+g[list or define global aliases]' \ '(-g +g -s +s)-+r[list or define regular aliases]' \ '(-r +r -g +g)-+s[list or define suffix aliases]' \ diff --git a/Completion/Zsh/Command/_bindkey b/Completion/Zsh/Command/_bindkey index df9c8f225..81016fe4f 100644 --- a/Completion/Zsh/Command/_bindkey +++ b/Completion/Zsh/Command/_bindkey @@ -10,7 +10,7 @@ local state expl line curcontext="$curcontext" ret=1 typeset -A opt_args -_arguments -C -s -S \ +_arguments -C -s -S -S : \ '(-v -a -M -l -D -A -N -p)-e[select emacs keymap and bind it to main]' \ '(-e -a -M -l -D -A -N -p)-v[select viins keymap and bind it to main]' \ '(-e -v -M -l -D -A -N -p)-a[select vicmd keymap]' \ diff --git a/Completion/Zsh/Command/_command b/Completion/Zsh/Command/_command index 503f860a2..02ff985c3 100644 --- a/Completion/Zsh/Command/_command +++ b/Completion/Zsh/Command/_command @@ -1,6 +1,6 @@ #compdef command -_arguments \ +_arguments -S : \ '-v[indicate result of command search]:*:command:_path_commands' \ '-V[show result of command search in verbose form]:*:command:_path_commands' \ '(-)-p[use default PATH to find command]' \ diff --git a/Completion/Zsh/Command/_compadd b/Completion/Zsh/Command/_compadd index 4456cf71e..e42e1dd36 100644 --- a/Completion/Zsh/Command/_compadd +++ b/Completion/Zsh/Command/_compadd @@ -88,7 +88,7 @@ case $service in ;; esac -_arguments -C -s -S -A "-*" $args && ret=0 +_arguments -C -s -S -S -A "-*" : $args && ret=0 if [[ -n $state ]]; then if (( $+opt_args[-a] )); then diff --git a/Completion/Zsh/Command/_dirs b/Completion/Zsh/Command/_dirs index 0281f3736..489366f08 100644 --- a/Completion/Zsh/Command/_dirs +++ b/Completion/Zsh/Command/_dirs @@ -1,6 +1,6 @@ #compdef dirs -_arguments -s \ +_arguments -s -S -S : \ '(-)-c[clear the directory stack]' \ '(* -c)-l[display directory names in full]' \ '(* -c)-v[display numbered list of directory stack]' \ diff --git a/Completion/Zsh/Command/_disable b/Completion/Zsh/Command/_disable index da3803039..c4cc00243 100644 --- a/Completion/Zsh/Command/_disable +++ b/Completion/Zsh/Command/_disable @@ -6,7 +6,7 @@ ali_arr=(${(k)aliases} ${(k)galiases}) sali_arr=(${(k)saliases}) func_arr=(${(k)functions}) -_arguments -C -s -A "-*" -S \ +_arguments -C -s -A "-*" -S -S : \ "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global alias:compadd -k ali_arr" \ "(-a -r -s -p)-f[act on functions]:*:function:compadd -k func_arr" \ "(-a -f -s -p)-r[act on reserved words]:*:reserved-word:compadd -k reswords" \ diff --git a/Completion/Zsh/Command/_emulate b/Completion/Zsh/Command/_emulate index a16738cdb..3477bc556 100644 --- a/Completion/Zsh/Command/_emulate +++ b/Completion/Zsh/Command/_emulate @@ -1,6 +1,6 @@ #compdef emulate -_arguments -s -S -A '-*' : \ +_arguments -s -S -S -A '-*' : \ '(2 3)-l[list options to be set or unset]' \ '(2 3)-L[set local_options and local_traps as well]' \ '-R[reset all options instead of only those needed for script portability]' \ diff --git a/Completion/Zsh/Command/_enable b/Completion/Zsh/Command/_enable index b62619d89..c581e49a3 100644 --- a/Completion/Zsh/Command/_enable +++ b/Completion/Zsh/Command/_enable @@ -6,7 +6,7 @@ ali_arr=(${(k)dis_aliases} ${(k)dis_galiases}) sali_arr=(${(k)dis_saliases}) func_arr=(${(k)dis_functions}) -_arguments -C -s -A "-*" -S \ +_arguments -C -s -A "-*" -S -S : \ "(-f -r -s -p)-a[act on regular or global aliases]:*:alias:compadd -k ali_arr" \ "(-a -r -s -p)-f[act on functions]:*:function:compadd -k func_arr" \ "(-a -f -s -p)-r[act on reserved words]:*:reserved-word:compadd -k dis_reswords" \ diff --git a/Completion/Zsh/Command/_exec b/Completion/Zsh/Command/_exec index 2498b57c0..76f11b69d 100644 --- a/Completion/Zsh/Command/_exec +++ b/Completion/Zsh/Command/_exec @@ -1,6 +1,6 @@ #compdef exec -_arguments -s -S -A '-*' : \ +_arguments -s -S -S -A '-*' : \ '-a+[set argv\[0\] to specified string]:argv[0] string' \ '-c[clear environment]' \ '-l[simulate login shell (prepend - to argv\[0\])]' \ diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc index 626d35956..fc35114f5 100644 --- a/Completion/Zsh/Command/_fc +++ b/Completion/Zsh/Command/_fc @@ -12,7 +12,7 @@ words=( "${(@)words[1,CURRENT-1]:#*=*}" "${(@)words[CURRENT,-1]}" ) (( CURRENT -= cur )) fc_common=( - -s -S + -s -S -S : '(-A -R -W -p -P)-I[include internal (new) events only]' '(-A -R -W -p -P)-L[include local events only]' '(-A -R -W -p -P)-r[reverse order of the events]' diff --git a/Completion/Zsh/Command/_hash b/Completion/Zsh/Command/_hash index d4bb59d28..b7af750c2 100644 --- a/Completion/Zsh/Command/_hash +++ b/Completion/Zsh/Command/_hash @@ -9,7 +9,7 @@ common_args=( \ case ${service} in hash) - _arguments -C -s -S \ + _arguments -C -s -S -S : \ '(-f -m -v)-r[empty hash table]' \ '(-f -r)-m[treat arguments as patterns]' \ '(-f -r -m)-v[list entries as they are added]' \ @@ -18,7 +18,7 @@ case ${service} in '(-d -f -r -m -v -L)*:hash:->hashval' && ret=0 ;; rehash) - _arguments -C -s ${common_args[@]} && return 0 + _arguments -C -s -S -S : ${common_args[@]} && return 0 ;; esac diff --git a/Completion/Zsh/Command/_jobs_builtin b/Completion/Zsh/Command/_jobs_builtin index 70804cf0f..46146986b 100644 --- a/Completion/Zsh/Command/_jobs_builtin +++ b/Completion/Zsh/Command/_jobs_builtin @@ -1,6 +1,6 @@ #compdef jobs -_arguments -C -s \ +_arguments -C -s -S -S : \ "(-d -l -p -r -s *)-Z[specify string to replace shell's argument and environment with]:string" \ '(-Z)-d[show directory from which each job was started]' \ '(-Z)-l[list process IDs]' \ diff --git a/Completion/Zsh/Command/_kill b/Completion/Zsh/Command/_kill index 3b5c02151..24bf67fac 100644 --- a/Completion/Zsh/Command/_kill +++ b/Completion/Zsh/Command/_kill @@ -3,7 +3,7 @@ local curcontext="$curcontext" line state ret=1 typeset -A opt_args -_arguments -C \ +_arguments -C -s -S -S : \ '(-s -l -L 1)-n[specify signal number]:signal number' \ '(-l -L)-q[send the specified integer with the signal using sigqueue]:value' \ '(-n -l -L 1)-s[specify signal name]:signal:_signals -s' \ diff --git a/Completion/Zsh/Command/_print b/Completion/Zsh/Command/_print index 0610cd4cf..506bf8ca6 100644 --- a/Completion/Zsh/Command/_print +++ b/Completion/Zsh/Command/_print @@ -19,7 +19,7 @@ if [[ $service = print ]]; then rest='*: :_default' fi - _arguments -C -s -A "-*" -S \ + _arguments -C -s -A "-*" -S -S : \ '-r[ignore escape conventions of echo]' \ '(-r -b -f -m -s -S -l -N -o -O -i -c -u -p -z -D -P)-R[emulate BSD echo (no escapes, -n & -e flags only)]' \ '-b[recognise bindkey escape sequences]' \ diff --git a/Completion/Zsh/Command/_prompt b/Completion/Zsh/Command/_prompt index ef6aac355..e44d02e0f 100644 --- a/Completion/Zsh/Command/_prompt +++ b/Completion/Zsh/Command/_prompt @@ -1,6 +1,6 @@ #compdef prompt -_arguments -s \ +_arguments -s -S : \ '-l[list themes]:*:' \ '-c[show selected theme]:*:' \ "-h[help]::prompt theme:($prompt_themes):*:" \ diff --git a/Completion/Zsh/Command/_read b/Completion/Zsh/Command/_read index 1f733b0e8..e71531c31 100644 --- a/Completion/Zsh/Command/_read +++ b/Completion/Zsh/Command/_read @@ -6,7 +6,7 @@ local pflag (:>&p) 2>/dev/null && pflag='(-q -s -u -z)-p[input is read from the coprocess]' -_arguments -s -A "-*" -S \ +_arguments -s -A "-*" -S -S : \ '-r[raw mode]' \ '(-p -k -s -u -z)-q[read y or n character from terminal]' \ '(-q)-k+[specify number of characters to read]:: :_guard "[0-9]#" "number of characters"' \ diff --git a/Completion/Zsh/Command/_set b/Completion/Zsh/Command/_set index 720c667a9..5939b48af 100644 --- a/Completion/Zsh/Command/_set +++ b/Completion/Zsh/Command/_set @@ -1,6 +1,6 @@ #compdef set -noglob _arguments -s -S \ +noglob _arguments -s -S -S : \ - list '+[list names of parameters]' - others \ '-o+[set specified option]:option:_options' \ '+o+[unset specified option]:option:_options' \ diff --git a/Completion/Zsh/Command/_strftime b/Completion/Zsh/Command/_strftime index a57a76ce4..fce1f5d95 100644 --- a/Completion/Zsh/Command/_strftime +++ b/Completion/Zsh/Command/_strftime @@ -6,7 +6,7 @@ if (( words[(I)-r] )); then two='date string' fi -_arguments -S -A '-*' -s \ +_arguments -S -S -A '-*' -s : \ '-n[omit trailing newline]' \ '-q[run quietly]' \ '(3)-r[reverse lookup using strptime]' \ diff --git a/Completion/Zsh/Command/_tcpsys b/Completion/Zsh/Command/_tcpsys index 1240ffbf8..c22a2c3a8 100644 --- a/Completion/Zsh/Command/_tcpsys +++ b/Completion/Zsh/Command/_tcpsys @@ -21,7 +21,7 @@ case $service in else argargs+=(':host:_hosts' ':port:_ports' '*:session:->session') fi - _arguments -C $argargs + _arguments -C -s -S : $argargs ;; esac diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index 99b9e7e0d..895a3aa5d 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -93,7 +93,7 @@ for ((i=1;i<=$#use;++i)); do args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[dUurRtT]]:+$func}]} ) done -_arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq' && ret=0 +_arguments -C -s -A "-*" -S -S : "${args[@]}" '*::vars:= ->vars_eq' && ret=0 if [[ "$state" = vars_eq ]]; then if [[ $func = f ]]; then diff --git a/Completion/Zsh/Command/_unhash b/Completion/Zsh/Command/_unhash index ff0c03f49..97ccd098a 100644 --- a/Completion/Zsh/Command/_unhash +++ b/Completion/Zsh/Command/_unhash @@ -1,6 +1,6 @@ #compdef unhash -_arguments -s -S \ +_arguments -s -S -S : \ '(-a -f -s *)-d[remove named directories]:*:named directory:compadd -k nameddirs' \ '(-d -f -s *)-a[remove aliases]:*:alias:_aliases' \ '(-a -d -f *)-s[remove suffix aliases]:*:suffix alias:_aliases -s s' \ diff --git a/Completion/Zsh/Command/_vared b/Completion/Zsh/Command/_vared index e7072ca6d..493bae698 100644 --- a/Completion/Zsh/Command/_vared +++ b/Completion/Zsh/Command/_vared @@ -1,6 +1,6 @@ #compdef vared -_arguments -s -A "-*" \ +_arguments -s -S -S -A "-*" : \ '(-a)-A[edit associative array]' \ '(-A)-a[edit array parameter]' \ "-c[create parameter or change type]" \ diff --git a/Completion/Zsh/Command/_which b/Completion/Zsh/Command/_which index 7eb5129ab..95ad5ab2d 100644 --- a/Completion/Zsh/Command/_which +++ b/Completion/Zsh/Command/_which @@ -15,14 +15,14 @@ xarg='-x+[specify spaces to use for indentation in function expansion]: :_number case ${service} in whence) - _arguments -C -s -A "-*" -S \ + _arguments -C -s -A "-*" -S -S : \ '(-c -w)-v[verbose output]' \ '(-v -w)-c[csh-like output]' \ "${cargs[@]}" "$farg" "$aarg" "$xarg" && ret=0 ;; - where) _arguments -C -s -A "-*" -S "${cargs[@]}" "$xarg" && ret=0;; - which) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" "$xarg" && ret=0;; - type) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" "$farg" && ret=0;; + where) _arguments -C -s -A "-*" -S -S : "${cargs[@]}" "$xarg" && ret=0;; + which) _arguments -C -s -A "-*" -S -S : "${cargs[@]}" "$aarg" "$xarg" && ret=0;; + type) _arguments -C -s -A "-*" -S -S : "${cargs[@]}" "$aarg" "$farg" && ret=0;; esac if [[ "$state" = command ]]; then diff --git a/Completion/Zsh/Command/_zattr b/Completion/Zsh/Command/_zattr index e48047f6c..c7033de71 100644 --- a/Completion/Zsh/Command/_zattr +++ b/Completion/Zsh/Command/_zattr @@ -4,24 +4,24 @@ local context state line expl ret=1 REPLY case $service in zgetattr) -_arguments \ +_arguments -S -S : \ '1:file:_files' \ '2:attribute:->attrs' \ '3:parameter' ;; zsetattr) -_arguments \ +_arguments -S -S : \ '1:file:_files' \ '2:attribute:->attrs' \ '3:value' ;; zdelattr) -_arguments \ +_arguments -S -S : \ '1:file:_files' \ '2:attribute:->attrs' ;; zlistattr) -_arguments \ +_arguments -S -S : \ '1:file:_files' \ '2:parameter' ;; diff --git a/Completion/Zsh/Command/_zcompile b/Completion/Zsh/Command/_zcompile index 727ead3b1..f1d1e9ac9 100644 --- a/Completion/Zsh/Command/_zcompile +++ b/Completion/Zsh/Command/_zcompile @@ -3,7 +3,7 @@ local state line expl curcontext="$curcontext" ret=1 typeset -A opt_args -_arguments -C -s \ +_arguments -C -s -S -S -A '-*' : \ "(-t -c -m -a)-U[don't expand aliases]" \ '(-t -M)-R[mark as read]' \ '(-t -R)-M[mark as mapped]' \ diff --git a/Completion/Zsh/Command/_zed b/Completion/Zsh/Command/_zed index f84993d73..25763d3fb 100644 --- a/Completion/Zsh/Command/_zed +++ b/Completion/Zsh/Command/_zed @@ -1,11 +1,11 @@ #compdef zed fned histed case $service in -(fned) _arguments -S : ':shell function:_functions';; -(histed) _arguments -S : \ +(fned) _arguments -S -S : ':shell function:_functions';; +(histed) _arguments -S -S : \ '1:history file:_files' \ '2:history size: ';; -(zed) _arguments -S : \ +(zed) _arguments -s -S -S -A '-*' : \ '(-h 1 3 4)-f[edit function]' \ '(-h 1 3 4)-x+[specify spaces to use for indentation in function expansion]:spaces' \ '(-f -x 1 2)-h[edit history]' \ diff --git a/Completion/Zsh/Command/_zle b/Completion/Zsh/Command/_zle index 97ec8c875..ec83c38fa 100644 --- a/Completion/Zsh/Command/_zle +++ b/Completion/Zsh/Command/_zle @@ -15,7 +15,7 @@ compwids=(accept-and-menu-complete opts=(-A -C -D -F -L -M -N -R -T -U -a -c -l -r \* :) -_arguments -s -S \ +_arguments -s -S -S : \ "($opts)-A[define widget alias]:old widget:->widget :new widget:->widget" \ "($opts)-C[define completion widget]:new widget name:->comp-widget :completion widget:->builtin-comp-widget :widget shell function:->function" \ "($opts)-D[delete widget]:*:widget:->widget" \ @@ -36,14 +36,14 @@ _arguments -s -S \ '(-)*::widget args:->args' && ret=0 [[ $state == listing ]] && - _arguments -s -S '!-l' \ + _arguments -s -S -S : '!-l' \ "(-a)-L[list as commands]" \ "(-L)-a[list all widgets]" \ '*:widget name:->widget' && ret=0 case "$state[1]" in (args) - _arguments \ + _arguments -s -S : \ '(-N)-n[numeric prefix]:number:' \ '(-n)-N[reset numeric prefix]' \ '-K[specify temporary keymap]:keymap:compadd -a keymaps' \ @@ -67,7 +67,7 @@ case "$state[1]" in compadd -M 'r:|-=* r:|=*' -k "widgets[(I)(.|)(${(j(|))compwids})]" && ret=0 ;; (redisplay) - _arguments -s -S '!-R' \ + _arguments -s -S -S : '!-R' \ "-c[clear listing]" \ ":status line" "*:strings to list" && ret=0 ;; diff --git a/Completion/Zsh/Command/_zmodload b/Completion/Zsh/Command/_zmodload index f3e38c0f6..3acb75c6e 100644 --- a/Completion/Zsh/Command/_zmodload +++ b/Completion/Zsh/Command/_zmodload @@ -4,7 +4,7 @@ local suf comp state line expl curcontext="$curcontext" ret=1 NORMARG typeset -A opt_args suf=() -_arguments -n -C -S -s \ +_arguments -n -C -S -S -s -A '-*' : \ '(-R -P -i -u -d -a -b -c -I -p -f -e -F -m)-A[create module aliases]' \ '(-)-R[remove module aliases]' \ '(-A -R -F -L -m -P -l -e)-u[unload module]' \ diff --git a/Completion/Zsh/Command/_zmv b/Completion/Zsh/Command/_zmv index df5cb5113..8b4b60897 100644 --- a/Completion/Zsh/Command/_zmv +++ b/Completion/Zsh/Command/_zmv @@ -1,6 +1,6 @@ #compdef zmv zln zcp -_arguments -s -S -A '-*' \ +_arguments -s -S -S -A '-*' : \ '(-C -L -s -p)-M[force mv]' \ '(-M -L -s -p)-C[force cp]' \ '(-M -C -p)-L[force ln]' \ diff --git a/Completion/Zsh/Command/_zparseopts b/Completion/Zsh/Command/_zparseopts index cc5e28a9a..72dc787a4 100644 --- a/Completion/Zsh/Command/_zparseopts +++ b/Completion/Zsh/Command/_zparseopts @@ -4,7 +4,7 @@ local ret=1 local -a context line state state_descr alts opts local -A opt_args -_arguments -A '-*' : \ +_arguments -S -S -A '-*' : \ '-a+[specify array in which to store parsed options]:array:_parameters -g "*array*~*readonly*"' \ '-A+[specify association in which to store parsed options]:association:_parameters -g "*association*~*readonly*"' \ '-D[remove parsed options from positional parameters]' \ diff --git a/Completion/Zsh/Command/_zpty b/Completion/Zsh/Command/_zpty index 99251aa0a..75393ecf1 100644 --- a/Completion/Zsh/Command/_zpty +++ b/Completion/Zsh/Command/_zpty @@ -3,7 +3,7 @@ local state line list names expl sep curcontext="$curcontext" typeset -A opt_args -_arguments -C -s -S \ +_arguments -C -s -S -S -A '-*' : \ '(-r -w -t -n -L -d)-e[echo input characters]' \ '(-r -w -t -n -L -d)-b[io to pseudo-terminal blocking]' \ '(-r -w -t -n -L -e -b)-d[delete command]:*:name:->name' \ diff --git a/Completion/Zsh/Command/_zsocket b/Completion/Zsh/Command/_zsocket index eeed9f1d8..bf0298b17 100644 --- a/Completion/Zsh/Command/_zsocket +++ b/Completion/Zsh/Command/_zsocket @@ -1,6 +1,6 @@ #compdef zsocket -_arguments -s -w -A "-*" \ +_arguments -s -w -S -S -A "-*" : \ '-v[verbose output]' \ '-d[target file descriptor]:fd:_file_descriptors' \ - outbound \ diff --git a/Completion/Zsh/Function/__arguments b/Completion/Zsh/Function/__arguments index af7710971..1264d372b 100644 --- a/Completion/Zsh/Function/__arguments +++ b/Completion/Zsh/Function/__arguments @@ -32,7 +32,7 @@ else '-W[(rarely needed) enable single-letter option stacking with arguments in the same word (-x X -y == -xXy)]' \ "-C[modify \$curcontext for \`->action' (instead of \$context)]" \ "-R[when \`->action' matches, return 300]" \ - "-S[honour \`--' as end-of-options guard]" \ + "*-S[honour \`--' (and \`-' if given twice) as end-of-options guard]" \ "-A[do not complete options after non-options]:pattern matching unknown options (e.g., '-*')" \ '-O[pass elements of array variable to function calls in actions]:array variable name:_parameters -g array' \ "-M[specify matchspec for completing option names and values]:matchspec for completing option names and values [ 'r\\:|[_-]=* r\\:|=*' ]" \ diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 7f748ad73..9d20ea116 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -3702,6 +3702,10 @@ example(foobar -x -- -y) the `tt(-x)' is considered an option, the `tt(-y)' is considered an argument, and the `tt(-)tt(-)' is considered to be neither. + +If this option is given twice (as tt(-S -S)), a single `tt(-)' is also +treated this way. This is useful for completing zsh's own builtins as +well as functions that use tt(zparseopts) for option parsing. ) item(tt(-A) var(pat))( Do not complete options after the first non-option diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index 43018c2e5..44bd61712 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -921,7 +921,8 @@ struct cadef { char *nonarg; /* pattern for non-args (-A argument) */ }; -#define CDF_SEP 1 /* -S was specified: -- terminates options */ +#define CDF_SEP 1 /* -S was specified: -- terminates options */ +#define CDF_ZSEP 2 /* -S -S was specified: - terminates options */ /* Description for an option. */ @@ -1255,7 +1256,7 @@ parse_cadef(char *nam, char **args) if (*p == 's') single = 1; else if (*p == 'S') - flags |= CDF_SEP; + flags |= (flags & CDF_SEP) ? CDF_ZSEP : CDF_SEP; else if (*p == 'A') { if (p[1]) { nonarg = p + 1; @@ -2118,8 +2119,9 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first) ca_inactive(d, argxor, cur - 1, 0); argxor = NULL; } - if ((d->flags & CDF_SEP) && cur != compcurrent && state.actopts && - !strcmp(line, "--")) { + if (cur != compcurrent && state.actopts && + (((d->flags & CDF_SEP) && !strcmp(line, "--")) || + ((d->flags & CDF_ZSEP) && !strcmp(line, "-")))) { ca_inactive(d, NULL, cur, 1); state.actopts = 0; continue; diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst index 200c83e8c..6e423bfe5 100644 --- a/Test/Y03arguments.ztst +++ b/Test/Y03arguments.ztst @@ -373,20 +373,35 @@ tst_arguments -S -x ':word:()' comptest $'tst -- -\t' -0:disallowed option after -- +0:-S: disallowed option after -- >line: {tst -- -}{} tst_arguments -S -x ':word:()' + comptest $'tst - -\t' +0:-S: allowed option after - +>line: {tst - -x }{} + + tst_arguments -S -x ':word:()' comptest $'tst - --\eB\C-b\t' -0:allowed option before -- +0:-S: allowed option before -- >line: {tst -x }{ --} tst_arguments -S '1:one' '2:two' comptest $'tst -- -- \t' -0:only first of duplicate -- is ignored +0:-S: only first of duplicate -- is ignored >line: {tst -- -- }{} >DESCRIPTION:{two} + tst_arguments -S -S -x ':word:()' + comptest $'tst -- -\t' +0:-S -S: disallowed option after -- +>line: {tst -- -}{} + + tst_arguments -S -S -x ':word:()' + comptest $'tst - -\t' +0:-S -S: disallowed option after - +>line: {tst - -}{} + tst_arguments -x :word comptest $'tst word -\t' 0:option after a word |
