From bb36b80178e38adf67188a7367b88dd9de6b39db Mon Sep 17 00:00:00 2001 From: Sebastian Stark Date: Tue, 21 Feb 2023 23:12:47 +0100 Subject: 51470 (tweaked, c.f. 51476): Separate cdpath elements in path-directories completion --- Completion/Zsh/Command/_cd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd index 46237e73d..961d121e0 100644 --- a/Completion/Zsh/Command/_cd +++ b/Completion/Zsh/Command/_cd @@ -70,8 +70,15 @@ else tmpcdpath=(${${(@)cdpath:#.}:#$PWD}) - (( $#tmpcdpath )) && - alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' ) + if zstyle -t ":completion:${curcontext}:path-directories" separate-sections; then + local elem + for ((elem=1; elem <= $#tmpcdpath; elem++)); do + alt+=( "path-directories-$elem:directory in $tmpcdpath[$elem]:_path_files -W 'tmpcdpath[$elem]' -/" ) + done + else + (( $#tmpcdpath )) && + alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' ) + fi # With cdablevars, we can complete foo as if ~foo/ if [[ -o cdablevars && -n "$PREFIX" && "$PREFIX" != <-> ]]; then -- cgit v1.2.3 From 0577dafcaa9d5f7cdbf5637b2dea5ed71dd5af81 Mon Sep 17 00:00:00 2001 From: Stephane Chazelas Date: Fri, 2 Jun 2023 16:09:53 +0100 Subject: Protect some :s from history modifier expansion --- ChangeLog | 3 +++ Completion/Unix/Command/_ant | 4 ++-- Completion/Unix/Command/_ant.rej | 13 +++++++++++++ Completion/Unix/Command/_ffmpeg | 2 +- Completion/Unix/Command/_java | 4 ++-- Completion/Unix/Command/_subversion | 4 ++-- Completion/Zsh/Command/_cd | 2 +- 7 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 Completion/Unix/Command/_ant.rej (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index c760fccab..b94a009e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2023-06-06 Peter Stephenson + * Stephane: 51817: Protect some use of ':' from history modifier + interpreation. + * 51816: Doc/Zsh/expn.yo, Src/hist.c, Src/subst.c, Test/D04parameter.ztst: add :S history modifier with pattern match. diff --git a/Completion/Unix/Command/_ant b/Completion/Unix/Command/_ant index 7401c7449..36c7c0e89 100644 --- a/Completion/Unix/Command/_ant +++ b/Completion/Unix/Command/_ant @@ -79,8 +79,8 @@ case $state in compset -P '*:' compset -S ':*' _alternative \ - "classpath:$state:_path_files -qS: -g '*.(jar|zip)(-.)'" \ - "classpath:$state:_path_files -r': ' -/" && ret=0 + "classpath:${state}:_path_files -qS: -g '*.(jar|zip)(-.)'" \ + "classpath:${state}:_path_files -r': ' -/" && ret=0 ;; property) if compset -P 1 '*='; then diff --git a/Completion/Unix/Command/_ant.rej b/Completion/Unix/Command/_ant.rej new file mode 100644 index 000000000..15e26c9da --- /dev/null +++ b/Completion/Unix/Command/_ant.rej @@ -0,0 +1,13 @@ +--- Completion/Unix/Command/_ant ++++ Completion/Unix/Command/_ant +@@ -79,8 +79,8 @@ case $state in + compset -P '*:' + compset -S ':*' + _alternative \ +- "classpath:$state:_path_files -qS: -g '*.(jar|zip)(-.)'" \ +- "classpath:$state:_path_files -r': ' -/" && ret=0 ++ "classpath:${state}:_path_files -qS: -g '*.(jar|zip)(-.)'" \ ++ "classpath:${state}:_path_files -r': ' -/" && ret=0 + ;; + property) + if compset -P 1 '*='; then diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg index 1329939cd..e5afdac4f 100644 --- a/Completion/Unix/Command/_ffmpeg +++ b/Completion/Unix/Command/_ffmpeg @@ -125,7 +125,7 @@ local -a _ffmpeg_argspecs lastopt_description=${lastopt_description//:/\\:} if [[ $example == filename ]]; then lastopt_takesargs=0 - lastopt+=":$lastopt_description:_files" + lastopt+=":${lastopt_description}:_files" elif [[ $lastopt == -[asv]pre ]]; then lastopt_takesargs=0 lastopt="*$lastopt" diff --git a/Completion/Unix/Command/_java b/Completion/Unix/Command/_java index ff6e82645..b2352df7b 100644 --- a/Completion/Unix/Command/_java +++ b/Completion/Unix/Command/_java @@ -438,8 +438,8 @@ classpath|sourcepath|bootstrapclasspath|docletpath) compset -P '*:' compset -S ':*' _alternative \ - "classpath:$state:_path_files -qS: -g '*.(jar|zip)(-.)'" \ - "classpath:$state:_path_files -r': ' -/" && return + "classpath:${state}:_path_files -qS: -g '*.(jar|zip)(-.)'" \ + "classpath:${state}:_path_files -r': ' -/" && return ;; extdirs) diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index 9a0328dca..ccaf310fa 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -139,7 +139,7 @@ _svn () { ;; (commit) args=( - ${args/(#b)(*--file*):arg:/$match[1]:file:_files} + ${args/(#b)(*--file*):arg:/${match[1]}:file:_files} '*:file: _svn_modified "committable"' ) ;; @@ -189,7 +189,7 @@ _svn () { args=( ':propname:(svn:ignore svn:keywords svn:executable svn:eol-style svn:mime-type svn:externals svn:needs-lock svn:global-ignores svn:auto-props)' ':propval:->propset_propval' - ${args/(#b)(*--file*):arg:/$match[1]:file:_files} + ${args/(#b)(*--file*):arg:/${match[1]}:file:_files} '*:path or url: _alternative "files:file:_files" "urls:URL:_svn_urls"' ) ;; diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd index 961d121e0..9ca846c8f 100644 --- a/Completion/Zsh/Command/_cd +++ b/Completion/Zsh/Command/_cd @@ -73,7 +73,7 @@ else if zstyle -t ":completion:${curcontext}:path-directories" separate-sections; then local elem for ((elem=1; elem <= $#tmpcdpath; elem++)); do - alt+=( "path-directories-$elem:directory in $tmpcdpath[$elem]:_path_files -W 'tmpcdpath[$elem]' -/" ) + alt+=( "path-directories-${elem}:directory in ${tmpcdpath[$elem]}:_path_files -W 'tmpcdpath[$elem]' -/" ) done else (( $#tmpcdpath )) && -- cgit v1.2.3 From 2573786fd3e81e080189fd5e39be14034cc55bd1 Mon Sep 17 00:00:00 2001 From: Shotaro Aoyama Date: Thu, 2 Nov 2023 01:38:40 +0900 Subject: github #105: add "-I" for "zle" completion --- ChangeLog | 3 +++ Completion/Zsh/Command/_zle | 1 + 2 files changed, 4 insertions(+) (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index 1802e4a41..0c51a3464 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2023-11-08 Oliver Kiddle + * github #105: Shotaro Aoyama: Completion/Zsh/Command/_zle: + add "-I" for "zle" completion + * Eric Cook: 52168: Completion/Unix/Command/_xfconf-query: add completion for xfce's xfconf-query(1) diff --git a/Completion/Zsh/Command/_zle b/Completion/Zsh/Command/_zle index 0b8ef7a15..97ec8c875 100644 --- a/Completion/Zsh/Command/_zle +++ b/Completion/Zsh/Command/_zle @@ -23,6 +23,7 @@ _arguments -s -S \ \(${(j. .)opts:#-[La]}')-l+[list user-defined widgets]:*:-:->listing' \ \(${(j. .)opts:#-l}')-a[with -l, list all widgets]' \ "(: * ${(j. .)opts:#-[Lw]})-F[install file descriptor handler]:file descriptor:_file_descriptors::handler:_functions" \ + "($opts)-I[invalidate the current zle display]" \ "!($opts)-K:keymap:compadd -a keymaps" \ "($opts)-M[display message]:message: " \ "($opts)-N[define new widget]:widget name:->widget-or-function ::widget shell function:->function" \ -- cgit v1.2.3 From 618f842b464c090f4a6fb02a9f4d217be9270466 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Tue, 5 Dec 2023 18:49:42 +0100 Subject: 52326, 52372: add -q option to kill for sigqueue --- ChangeLog | 3 +++ Completion/Zsh/Command/_kill | 1 + Doc/Zsh/builtins.yo | 5 ++++- Src/jobs.c | 36 ++++++++++++++++++++++++++++++++++-- configure.ac | 1 + 5 files changed, 43 insertions(+), 3 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index aa995e0d2..cd3cd4e84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2023-12-05 Oliver Kiddle + * 52326, 52372: configure.ac, Src/jobs.c, Doc/Zsh/builtins.yo, + Completion/Zsh/Command/_kill: add -q option to kill for sigqueue + * 52373: Completion/Base/Utility/_numbers, Completion/Solaris/Command/_dumpadm, Completion/Unix/Command/_xz: fix _numbers for suffixes containing % and update affected functions diff --git a/Completion/Zsh/Command/_kill b/Completion/Zsh/Command/_kill index b9dfde3f0..084cf42c8 100644 --- a/Completion/Zsh/Command/_kill +++ b/Completion/Zsh/Command/_kill @@ -5,6 +5,7 @@ typeset -A opt_args _arguments -C \ '(-s -l 1)-n[specify signal number]:signal number' \ + '(-l)-q[send the specified integer with the signal using sigqueue]:value' \ '(-n -l 1)-s[specify signal name]:signal:_signals -s' \ '(-n -s)-l[list signal names or numbers of specified signals]:*:signal:_signals' \ '(-n -s -l)1::signal:_signals -p -s' \ diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index cab265a25..1aa807633 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -1143,7 +1143,7 @@ findex(kill) cindex(killing jobs) cindex(jobs, killing) xitem(tt(kill) [ tt(-s) var(signal_name) | tt(-n) var(signal_number) | \ -tt(-)var(sig) ] var(job) ...) +tt(-)var(sig) ] [ tt(-q) var(value) ] var(job) ...) item(tt(kill) tt(-l) [ var(sig) ... ])( Sends either tt(SIGTERM) or the specified signal to the given jobs or processes. @@ -1170,6 +1170,9 @@ tt(kill -IO) and tt(kill -POLL) have the same effect. Many systems will allow process IDs to be negative to kill a process group or zero to kill the current process group. + +The tt(-q) option allows an integer value to be sent with the signal +on systems that support tt(sigqueue+LPAR()RPAR()). ) findex(let) item(tt(let) var(arg) ...)( diff --git a/Src/jobs.c b/Src/jobs.c index a3b9f667a..4e9767ee4 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -2677,9 +2677,35 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) { int sig = SIGTERM; int returnval = 0; +#ifdef HAVE_SIGQUEUE + union sigval sigqueue_info; +#endif + int use_sigqueue = 0, got_sig = 0; + + while (*argv && **argv == '-') { + if (!use_sigqueue && (*argv)[1] == 'q' && (*argv)[2] == '\0') { + char *endp; + + if (!*++argv) { + zwarnnam(nam, "-q: argument expected"); + return 1; + } +#ifdef HAVE_SIGQUEUE + sigqueue_info.sival_int = +#endif + zstrtol(*argv, &endp, 10); + if (*endp) { + zwarnnam(nam, "invalid number: %s", *argv); + return 1; + } + use_sigqueue = 1; + argv++; + continue; + } + if (got_sig) + break; /* check for, and interpret, a signal specifier */ - if (*argv && **argv == '-') { if (idigit((*argv)[1])) { char *endp; /* signal specified by number */ @@ -2796,6 +2822,7 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) } } argv++; + got_sig = 1; } /* Discard the standard "-" and "--" option breaks */ @@ -2844,7 +2871,12 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) returnval++; } else { int pid = atoi(*argv); - if (kill(pid, sig) == -1) { + if ( +#ifdef HAVE_SIGQUEUE + use_sigqueue ? sigqueue(pid, sig, sigqueue_info) : +#endif + kill(pid, sig) == -1) + { zwarnnam("kill", "kill %s failed: %e", *argv, errno); returnval++; } diff --git a/configure.ac b/configure.ac index c5263035e..9cb6e032b 100644 --- a/configure.ac +++ b/configure.ac @@ -1299,6 +1299,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \ mkfifo _mktemp mkstemp \ waitpid wait3 \ sigaction sigblock sighold sigrelse sigsetmask sigprocmask \ + sigqueue \ killpg setpgid setpgrp tcsetpgrp tcgetattr nice \ gethostname gethostbyname2 getipnodebyname \ inet_aton inet_pton inet_ntop \ -- cgit v1.2.3 From 5331ff11c64d9d292f4fe817723af6e0a067fa1f Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Wed, 28 Feb 2024 00:21:11 +0100 Subject: 52594: support for POSIX real-time signals with kill and trap Also add new -L option to kill for a more verbose listing of signals --- ChangeLog | 9 ++++ Completion/Zsh/Command/_kill | 9 ++-- Doc/Zsh/builtins.yo | 6 ++- Doc/Zsh/params.yo | 5 +- Src/Modules/parameter.c | 2 +- Src/builtin.c | 30 ++++++------ Src/exec.c | 2 +- Src/hashtable.c | 20 ++++---- Src/init.c | 3 ++ Src/jobs.c | 113 +++++++++++++++++++++++++++++++++++++------ Src/params.c | 14 +++++- Src/signals.c | 84 +++++++++++++++++++++++++++++--- Src/signals.h | 9 ++++ Src/signames2.awk | 6 +-- 14 files changed, 249 insertions(+), 63 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index 684820f92..53038c221 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-02-28 Oliver Kiddle + + * 52594: Completion/Zsh/Command/_kill, Doc/Zsh/builtins.yo, + Doc/Zsh/params.yo, Src/Modules/parameter.c, Src/builtin.c, + Src/exec.c, Src/hashtable.c, Src/init.c, Src/jobs.c, Src/params.c, + Src/signals.c, Src/signals.h, Src/signames2.awk: support for + POSIX real-time signals with kill and trap and add -L option to + kill for more verbose listing of signals + 2024-02-24 Bart Schaefer * 52597: Src/math.c: fix multibyte and metafied character counts diff --git a/Completion/Zsh/Command/_kill b/Completion/Zsh/Command/_kill index 084cf42c8..3b5c02151 100644 --- a/Completion/Zsh/Command/_kill +++ b/Completion/Zsh/Command/_kill @@ -4,10 +4,11 @@ local curcontext="$curcontext" line state ret=1 typeset -A opt_args _arguments -C \ - '(-s -l 1)-n[specify signal number]:signal number' \ - '(-l)-q[send the specified integer with the signal using sigqueue]:value' \ - '(-n -l 1)-s[specify signal name]:signal:_signals -s' \ - '(-n -s)-l[list signal names or numbers of specified signals]:*:signal:_signals' \ + '(-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' \ + '-l[list signal names or numbers of specified signals]:*:signal:_signals' \ + '(- *)-L[list each signal and corresponding number]' \ '(-n -s -l)1::signal:_signals -p -s' \ '*:processes:->processes' && ret=0 diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 784089594..6318053d8 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -1144,7 +1144,8 @@ cindex(killing jobs) cindex(jobs, killing) xitem(tt(kill) [ tt(-s) var(signal_name) | tt(-n) var(signal_number) | \ tt(-)var(sig) ] [ tt(-q) var(value) ] var(job) ...) -item(tt(kill) tt(-l) [ var(sig) ... ])( +xitem(tt(kill) tt(-l) [ var(sig) ... ]) +item(tt(kill) tt(-L))( Sends either tt(SIGTERM) or the specified signal to the given jobs or processes. Signals are given by number or by names, with or without the `tt(SIG)' @@ -1158,7 +1159,8 @@ specified the signal names are listed. Otherwise, for each var(sig) that is a name, the corresponding signal number is listed. For each var(sig) that is a signal number or a number representing the exit status of a process which was terminated or -stopped by a signal the name of the signal is printed. +stopped by a signal the name of the signal is printed. The final +form with tt(-L) lists each signal name with its corresponding number. On some systems, alternative signal names are allowed for a few signals. Typical examples are tt(SIGCHLD) and tt(SIGCLD) or tt(SIGPOLL) and diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index a6fbe6723..8c5e67e70 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -953,7 +953,10 @@ has index 1, the signals are offset by 1 from the signal number used by the operating system. For example, on typical Unix-like systems tt(HUP) is signal number 1, but is referred to as tt($signals[2]). This is because of tt(EXIT) at position 1 in the array, which is used -internally by zsh but is not known to the operating system. +internally by zsh but is not known to the operating system. On many systems +there is a block of reserved or unused signal numbers before the POSIX +real-time signals so the array index can't be used as an accurate indicator +of their signal number. Use, for example, tt(kill -l SIGRTMIN) instead. ) vindex(TRY_BLOCK_ERROR) item(tt(TRY_BLOCK_ERROR) )( diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index a05ea2fe4..7441c30b8 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -309,7 +309,7 @@ setfunction(char *name, char *val, int dis) shfunc_set_sticky(shf); if (!strncmp(name, "TRAP", 4) && - (sn = getsignum(name + 4)) != -1) { + (sn = getsigidx(name + 4)) != -1) { if (settrap(sn, NULL, ZSIG_FUNC)) { freeeprog(shf->funcdef); zfree(shf, sizeof(*shf)); diff --git a/Src/builtin.c b/Src/builtin.c index f72d14da4..44dfed651 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3425,16 +3425,16 @@ bin_functions(char *name, char **argv, Options ops, int func) newsh->sticky = sticky_emulation_dup(shf->sticky, 0); /* is newsh a signal trap? (adapted from exec.c) */ if (!strncmp(s, "TRAP", 4)) { - int signum = getsignum(s + 4); - if (signum != -1) { - if (settrap(signum, NULL, ZSIG_FUNC)) { + int sigidx = getsigidx(s + 4); + if (sigidx != -1) { + if (settrap(sigidx, NULL, ZSIG_FUNC)) { freeeprog(newsh->funcdef); dircache_set(&newsh->filename, NULL); zfree(newsh, sizeof(*newsh)); return 1; } /* Remove any old node explicitly */ - removetrapnode(signum); + removetrapnode(sigidx); } } shfunctab->addnode(shfunctab, ztrdup(s), &newsh->node); @@ -3713,15 +3713,15 @@ bin_functions(char *name, char **argv, Options ops, int func) /* no flags, so just print */ printshfuncexpand(&shf->node, pflags, expand); } else if (on & PM_UNDEFINED) { - int signum = -1, ok = 1; + int sigidx = -1, ok = 1; if (!strncmp(*argv, "TRAP", 4) && - (signum = getsignum(*argv + 4)) != -1) { + (sigidx = getsigidx(*argv + 4)) != -1) { /* * Because of the possibility of alternative names, * we must remove the trap explicitly. */ - removetrapnode(signum); + removetrapnode(sigidx); } if (**argv == '/') { @@ -3757,8 +3757,8 @@ bin_functions(char *name, char **argv, Options ops, int func) shfunc_set_sticky(shf); add_autoload_function(shf, *argv); - if (signum != -1) { - if (settrap(signum, NULL, ZSIG_FUNC)) { + if (sigidx != -1) { + if (settrap(sigidx, NULL, ZSIG_FUNC)) { shfunctab->removenode(shfunctab, *argv); shfunctab->freenode(&shf->node); returnval = 1; @@ -7346,7 +7346,7 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) /* If given no arguments, list all currently-set traps */ if (!*argv) { queue_signals(); - for (sig = 0; sig < VSIGCOUNT; sig++) { + for (sig = 0; sig < TRAPCOUNT; sig++) { if (sigtrapped[sig] & ZSIG_FUNC) { HashNode hn; @@ -7372,13 +7372,13 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) /* If we have a signal number, unset the specified * * signals. With only -, remove all traps. */ - if ((getsignum(*argv) != -1) || (!strcmp(*argv, "-") && argv++)) { + if ((getsigidx(*argv) != -1) || (!strcmp(*argv, "-") && argv++)) { if (!*argv) { - for (sig = 0; sig < VSIGCOUNT; sig++) + for (sig = 0; sig < TRAPCOUNT; sig++) unsettrap(sig); } else { for (; *argv; argv++) { - sig = getsignum(*argv); + sig = getsigidx(*argv); if (sig == -1) { zwarnnam(name, "undefined signal: %s", *argv); break; @@ -7403,12 +7403,12 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) Eprog t; int flags; - sig = getsignum(*argv); + sig = getsigidx(*argv); if (sig == -1) { zwarnnam(name, "undefined signal: %s", *argv); break; } - if (idigit(**argv) || + if (idigit(**argv) || (sig >= VSIGCOUNT) || !strcmp(sigs[sig], *argv) || (!strncmp("SIG", *argv, 3) && !strcmp(sigs[sig], *argv+3))) { /* The signal was specified by number or by canonical name (with diff --git a/Src/exec.c b/Src/exec.c index 0750738ce..d85adbea5 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -5427,7 +5427,7 @@ execfuncdef(Estate state, Eprog redir_prog) } else { /* is this shell function a signal trap? */ if (!strncmp(s, "TRAP", 4) && - (signum = getsignum(s + 4)) != -1) { + (signum = getsigidx(s + 4)) != -1) { if (settrap(signum, NULL, ZSIG_FUNC)) { freeeprog(shf->funcdef); dircache_set(&shf->filename, NULL); diff --git a/Src/hashtable.c b/Src/hashtable.c index bb165505e..75b06c4ad 100644 --- a/Src/hashtable.c +++ b/Src/hashtable.c @@ -836,10 +836,10 @@ static HashNode removeshfuncnode(UNUSED(HashTable ht), const char *nam) { HashNode hn; - int signum; + int sigidx; - if (!strncmp(nam, "TRAP", 4) && (signum = getsignum(nam + 4)) != -1) - hn = removetrap(signum); + if (!strncmp(nam, "TRAP", 4) && (sigidx = getsigidx(nam + 4)) != -1) + hn = removetrap(sigidx); else hn = removehashnode(shfunctab, nam); @@ -856,10 +856,10 @@ disableshfuncnode(HashNode hn, UNUSED(int flags)) { hn->flags |= DISABLED; if (!strncmp(hn->nam, "TRAP", 4)) { - int signum = getsignum(hn->nam + 4); - if (signum != -1) { - sigtrapped[signum] &= ~ZSIG_FUNC; - unsettrap(signum); + int sigidx = getsigidx(hn->nam + 4); + if (sigidx != -1) { + sigtrapped[sigidx] &= ~ZSIG_FUNC; + unsettrap(sigidx); } } } @@ -876,9 +876,9 @@ enableshfuncnode(HashNode hn, UNUSED(int flags)) shf->node.flags &= ~DISABLED; if (!strncmp(shf->node.nam, "TRAP", 4)) { - int signum = getsignum(shf->node.nam + 4); - if (signum != -1) { - settrap(signum, NULL, ZSIG_FUNC); + int sigidx = getsigidx(shf->node.nam + 4); + if (sigidx != -1) { + settrap(sigidx, NULL, ZSIG_FUNC); } } } diff --git a/Src/init.c b/Src/init.c index 83b79d3d4..ec21521b1 100644 --- a/Src/init.c +++ b/Src/init.c @@ -1382,6 +1382,9 @@ setupshin(char *runscript) void init_signals(void) { + sigtrapped = (int *) hcalloc(TRAPCOUNT * sizeof(int)); + siglists = (Eprog *) hcalloc(TRAPCOUNT * sizeof(Eprog)); + if (interact) { int i; signal_setmask(signal_mask(0)); diff --git a/Src/jobs.c b/Src/jobs.c index 118c5e61b..49decc661 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -1073,6 +1073,21 @@ should_report_time(Job j) return 0; } +/**/ +char * +sigmsg(int sig) +{ + static char *unknown = "unknown signal"; +#if defined(SIGRTMIN) && defined(SIGRTMAX) + static char rtmsg[] = "real-time event XXX"; + if (sig >= SIGRTMIN && sig <= SIGRTMAX) { + sprintf(rtmsg + sizeof(rtmsg) - 4, "%u", sig - SIGRTMIN + 1); + return rtmsg; + } +#endif + return sig <= SIGCOUNT ? sig_msg[sig] : unknown; +} + /* !(lng & 3) means jobs * * (lng & 1) means jobs -l * * (lng & 2) means jobs -p @@ -2694,7 +2709,7 @@ static const struct { int bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) { - int sig = SIGTERM; + int status, sig = SIGTERM; int returnval = 0; #ifdef HAVE_SIGQUEUE union sigval sigqueue_info; @@ -2740,23 +2755,29 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) if ((*argv)[1] == 'l' && (*argv)[2] == '\0') { if (argv[1]) { while (*++argv) { - sig = zstrtol(*argv, &signame, 10); + status = zstrtol(*argv, &signame, 10); if (signame == *argv) { + signame = casemodify(signame, CASMOD_UPPER); if (!strncmp(signame, "SIG", 3)) signame += 3; for (sig = 1; sig <= SIGCOUNT; sig++) - if (!strcasecmp(sigs[sig], signame)) + if (!strcmp(sigs[sig], signame)) break; if (sig > SIGCOUNT) { int i; for (i = 0; alt_sigs[i].name; i++) - if (!strcasecmp(alt_sigs[i].name, signame)) + if (!strcmp(alt_sigs[i].name, signame)) { sig = alt_sigs[i].num; break; } } +#if defined(SIGRTMIN) && defined(SIGRTMAX) + if (sig > SIGCOUNT && (sig = rtsigno(signame))) { + printf("%d\n", sig); + } else +#endif if (sig > SIGCOUNT) { zwarnnam(nam, "unknown signal: SIG%s", signame); @@ -2769,14 +2790,15 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) signame); returnval++; } else { - if (WIFSIGNALED(sig)) - sig = WTERMSIG(sig); - else if (WIFSTOPPED(sig)) - sig = WSTOPSIG(sig); + sig = status & ~0200; if (1 <= sig && sig <= SIGCOUNT) printf("%s\n", sigs[sig]); +#if defined(SIGRTMIN) && defined(SIGRTMAX) + else if ((signame = rtsigname(sig, 0))) + printf("%s\n", signame); +#endif else - printf("%d\n", sig); + printf("%d\n", status); } } } @@ -2785,10 +2807,42 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) printf("%s", sigs[1]); for (sig = 2; sig <= SIGCOUNT; sig++) printf(" %s", sigs[sig]); +#if defined(SIGRTMIN) && defined(SIGRTMAX) + for (sig = SIGRTMIN; sig <= SIGRTMAX; sig++) + printf(" %s", rtsigname(sig, 0)); +#endif putchar('\n'); return 0; } + /* with argument "-L" list signals with their numbers in a table */ + if ((*argv)[1] == 'L' && (*argv)[2] == '\0') { +#if defined(SIGRTMIN) && defined(SIGRTMAX) + const int width = SIGRTMAX >= 100 ? 3 : 2; +#else + const int width = SIGCOUNT >= 100 ? 3 : 2; +#endif + for (sig = 1; sig < SIGCOUNT +#if defined(SIGRTMIN) && defined(SIGRTMAX) + + 1 +#endif + ; sig++) + { + printf("%*d) %-10s%c", width, sig, sigs[sig], + sig % 5 ? ' ' : '\n'); + } +#if defined(SIGRTMIN) && defined(SIGRTMAX) + for (sig = SIGRTMIN; sig < SIGRTMAX; sig++) { + printf("%*d) %-10s%c", width, sig, rtsigname(sig, 0), + (sig - SIGRTMIN + SIGCOUNT + 1) % 5 ? ' ' : '\n'); + } + printf("%*d) RTMAX\n", width, sig); +#else + printf("%*d) %s\n", width, sig, sigs[sig]); +#endif + return 0; + } + if ((*argv)[1] == 'n' && (*argv)[2] == '\0') { char *endp; @@ -2833,9 +2887,13 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) break; } } - if (sig > SIGCOUNT) { + if (sig > SIGCOUNT +#if defined(SIGRTMIN) && defined(SIGRTMAX) + && !(sig = rtsigno(signame)) +#endif + ) { zwarnnam(nam, "unknown signal: SIG%s", signame); - zwarnnam(nam, "type kill -l for a list of signals"); + zwarnnam(nam, "type kill -L for a list of signals"); return 1; } } @@ -2916,18 +2974,19 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) return returnval < 126 ? returnval : 1; } -/* Get a signal number from a string */ + +/* Get index into table of traps from a string describing a signal */ /**/ mod_export int -getsignum(const char *s) +getsigidx(const char *s) { int x, i; /* check for a signal specified by number */ x = atoi(s); - if (idigit(*s) && x >= 0 && x < VSIGCOUNT) - return x; + if (idigit(*s) && x >= 0) + return SIGIDX(x); /* search for signal by name */ if (!strncmp(s, "SIG", 3)) @@ -2943,11 +3002,16 @@ getsignum(const char *s) return alt_sigs[i].num; } +#if defined(SIGRTMIN) && defined(SIGRTMAX) + if ((x = rtsigno(s))) + return SIGIDX(x); +#endif + /* no matching signal */ return -1; } -/* Get the name for a signal. */ +/* Get the name for a signal given the index into the traps table. */ /**/ mod_export const char * @@ -2961,6 +3025,11 @@ getsigname(int sig) return alt_sigs[i].name; } else +#if defined(SIGRTMIN) && defined(SIGRTMAX) + if (sig >= VSIGCOUNT) + return rtsigname(SIGNUM(sig), 0); + else +#endif return sigs[sig]; /* shouldn't reach here */ @@ -2985,10 +3054,22 @@ gettrapnode(int sig, int ignoredisable) else getptr = shfunctab->getnode; +#if defined(SIGRTMIN) && defined(SIGRTMAX) + if (sig >= VSIGCOUNT) + sprintf(fname, "TRAP%s", rtsigname(SIGNUM(sig), 0)); + else +#endif sprintf(fname, "TRAP%s", sigs[sig]); if ((hn = getptr(shfunctab, fname))) return hn; +#if defined(SIGRTMIN) && defined(SIGRTMAX) + if (sig >= VSIGCOUNT) { + sprintf(fname, "TRAP%s", rtsigname(SIGNUM(sig), 1)); + return getptr(shfunctab, fname); + } +#endif + for (i = 0; alt_sigs[i].name; i++) { if (alt_sigs[i].num == sig) { sprintf(fname, "TRAP%s", alt_sigs[i].name); diff --git a/Src/params.c b/Src/params.c index 225acb8a1..7c5e9d8ff 100644 --- a/Src/params.c +++ b/Src/params.c @@ -946,8 +946,18 @@ createparamtable(void) setsparam("ZSH_ARGZERO", ztrdup(posixzero)); setsparam("ZSH_VERSION", ztrdup_metafy(ZSH_VERSION)); setsparam("ZSH_PATCHLEVEL", ztrdup_metafy(ZSH_PATCHLEVEL)); - setaparam("signals", sigptr = zalloc((SIGCOUNT+4) * sizeof(char *))); - for (t = sigs; (*sigptr++ = ztrdup_metafy(*t++)); ); + setaparam("signals", sigptr = zalloc((TRAPCOUNT + 1) * sizeof(char *))); + t = sigs; +#if defined(SIGRTMIN) && defined(SIGRTMAX) + while (t - sigs <= SIGCOUNT) + *sigptr++ = ztrdup_metafy(*t++); + { + int sig; + for (sig = SIGRTMIN; sig <= SIGRTMAX; sig++) + *sigptr++ = ztrdup_metafy(rtsigname(sig, 0)); + } +#endif + while ((*sigptr++ = ztrdup_metafy(*t++))) /* empty */ ; noerrs = 0; } diff --git a/Src/signals.c b/Src/signals.c index b1a843e2c..d28853ea6 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -31,10 +31,12 @@ #include "signals.pro" /* Array describing the state of each signal: an element contains * - * 0 for the default action or some ZSIG_* flags ored together. */ + * 0 for the default action or some ZSIG_* flags ored together. * + * Contains TRAPCOUNT elements but can't be allocated statically * + * because that's a dynamic value on Linux */ /**/ -mod_export int sigtrapped[VSIGCOUNT]; +mod_export int *sigtrapped; /* * Trap programme lists for each signal. @@ -48,7 +50,7 @@ mod_export int sigtrapped[VSIGCOUNT]; */ /**/ -mod_export Eprog siglists[VSIGCOUNT]; +mod_export Eprog *siglists; /* Total count of trapped signals */ @@ -892,7 +894,7 @@ dosavetrap(int sig, int level) * Set a trap: note this does not handle manipulation of * the function table for TRAPNAL functions. * - * sig is the signal number. + * sig is index into the table of trapped signals. * * l is the list to be eval'd for a trap defined with the "trap" * builtin and should be NULL for a function trap. @@ -931,6 +933,10 @@ settrap(int sig, Eprog l, int flags) #endif sig != SIGCHLD) signal_ignore(sig); +#if defined(SIGRTMIN) && defined(SIGRTMAX) + else if (sig >= VSIGCOUNT && sig < TRAPCOUNT) + signal_ignore(SIGNUM(sig)); +#endif } else { nsigtrapped++; sigtrapped[sig] = ZSIG_TRAPPED; @@ -940,6 +946,10 @@ settrap(int sig, Eprog l, int flags) #endif sig != SIGCHLD) install_handler(sig); +#if defined(SIGRTMIN) && defined(SIGRTMAX) + if (sig >= VSIGCOUNT && sig < TRAPCOUNT) + install_handler(SIGNUM(sig)); +#endif } sigtrapped[sig] |= flags; /* @@ -1019,6 +1029,11 @@ removetrap(int sig) #endif sig != SIGCHLD) signal_default(sig); +#if defined(SIGRTMIN) && defined(SIGRTMAX) + else if (sig >= VSIGCOUNT && sig < TRAPCOUNT) + signal_default(SIGNUM(sig)); +#endif + if (sig == SIGEXIT) exit_trap_posix = 0; @@ -1172,7 +1187,7 @@ endtrapscope(void) static int handletrap(int sig) { - if (!sigtrapped[sig]) + if (!sigtrapped[SIGIDX(sig)]) return 0; if (trap_queueing_enabled) @@ -1189,7 +1204,7 @@ handletrap(int sig) return 1; } - dotrap(sig); + dotrap(SIGIDX(sig)); if (sig == SIGALRM) { @@ -1481,3 +1496,60 @@ dotrap(int sig) restore_queue_signals(q); } + +#if defined(SIGRTMIN) && defined(SIGRTMAX) + +/* Realtime signals, these are a contiguous block that can + * be separated from the other signals with an unused gap. */ + +/**/ +int +rtsigno(const char* signame) +{ + const int maxofs = SIGRTMAX - SIGRTMIN; + const char *end = signame + 5; + int offset; + struct rtdir { int sig; int dir; char op; } x = { 0, 0, 0 }; + if (!strncmp(signame, "RTMIN", 5)) { + x = (struct rtdir) { SIGRTMIN, 1, '+' }; + } else if (!strncmp(signame, "RTMAX", 5)) { + x = (struct rtdir) { SIGRTMAX, -1, '-' }; + } else + return 0; + + if (signame[5] == x.op) { + if ((offset = strtol(signame + 6, (char **) &end, 10)) > maxofs) + return 0; + x.sig += offset * x.dir; + } + if (*end) + return 0; + + return x.sig; +} + +/**/ +char * +rtsigname(int signo, int alt) +{ + char* buf = (char *) zhalloc(10); + int minofs = signo - SIGRTMIN; + int maxofs = SIGRTMAX - signo; + int offset; + int form = alt ^ (maxofs < minofs); + + if (signo < SIGRTMIN || signo > SIGRTMAX) + return NULL; + + strcpy(buf, "RT"); + strcpy(buf+2, form ? "MAX-" : "MIN+"); + offset = form ? maxofs : minofs; + if (offset) { + snprintf(buf + 6, 4, "%d", offset); + } else { + buf[5] = '\0'; + } + return buf; +} + +#endif diff --git a/Src/signals.h b/Src/signals.h index 41ac88cce..391f11fed 100644 --- a/Src/signals.h +++ b/Src/signals.h @@ -36,6 +36,15 @@ #define SIGZERR (SIGCOUNT+1) #define SIGDEBUG (SIGCOUNT+2) #define VSIGCOUNT (SIGCOUNT+3) +#if defined(SIGRTMIN) && defined(SIGRTMAX) +# define TRAPCOUNT (VSIGCOUNT + SIGRTMAX - SIGRTMIN + 1) +# define SIGNUM(x) ((x) >= VSIGCOUNT ? (x) - VSIGCOUNT + SIGRTMIN : (x)) +# define SIGIDX(x) ((x) >= SIGRTMIN && (x) <= SIGRTMAX ? (x) - SIGRTMIN + VSIGCOUNT : (x)) +#else +# define TRAPCOUNT VSIGCOUNT +# define SIGNUM(x) (x) +# define SIGIDX(x) (x) +#endif #define SIGEXIT 0 #ifdef SV_BSDSIG diff --git a/Src/signames2.awk b/Src/signames2.awk index 4d1557cd8..5738030c6 100644 --- a/Src/signames2.awk +++ b/Src/signames2.awk @@ -15,7 +15,7 @@ if (signam == "CHLD" && sig[signum] == "CLD") sig[signum] = "" if (signam == "POLL" && sig[signum] == "IO") sig[signum] = "" if (signam == "ABRT" && sig[signum] == "IOT") sig[signum] = "" - if (sig[signum] == "") { + if (signam !~ /RTM(IN|AX)/ && sig[signum] == "") { sig[signum] = signam if (0 + max < 0 + signum && signum < 60) max = signum @@ -66,10 +66,6 @@ END { printf "#include %czsh.mdh%c\n", 34, 34 printf "\n" printf "/**/\n" - printf "#define sigmsg(sig) ((sig) <= SIGCOUNT ? sig_msg[sig]" - printf " : %c%s%c)", 34, "unknown signal", 34 - printf "\n" - printf "/**/\n" printf "mod_export char *sig_msg[SIGCOUNT+2] = {\n" printf "\t%c%s%c,\n", 34, "done", 34 -- cgit v1.2.3 From a967c4a4357e05710139ffaa87017ac00f9d04fa Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 1 Apr 2024 23:27:09 +0200 Subject: 52859: use _date_formats for fc and complete -m/-M for vared --- ChangeLog | 5 +++++ Completion/Zsh/Command/_fc | 2 +- Completion/Zsh/Command/_vared | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index 582f75635..4e43cac03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-04-01 Oliver Kiddle + + * 52859: Completion/Zsh/Command/_fc, Completion/Zsh/Command/_vared: + use _date_formats for fc and complete -m/-M for vared + 2024-03-25 Oliver Kiddle * 52798: Completion/Unix/Command/_ssh, diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc index 80e570c5d..626d35956 100644 --- a/Completion/Zsh/Command/_fc +++ b/Completion/Zsh/Command/_fc @@ -40,7 +40,7 @@ fc_hist=( '(-A -R -W -e -d -E -i -t -a -p -P)-f[mm/dd/yyyy format time-stamps]' '(-A -R -W -e -d -f -i -t -a -p -P)-E[dd.mm.yyyy format time-stamps]' '(-A -R -W -e -d -f -E -t -a -p -P)-i[yyyy-mm-dd format time-stamps]' - '(-A -R -W -e -d -f -E -i -a -p -P)-t[print time-stamps in specified format]:date format' + '(-A -R -W -e -d -f -E -i -a -p -P)-t[print time-stamps in specified format]: : _date_formats zsh' '(-A -R -W -e -a -p -P)-D[print elapsed times]' '(-A -R -W -I -e -d -f -i -l -m -n -r -D -E -t -P)-a[with -p, automatically pop history on function return]' diff --git a/Completion/Zsh/Command/_vared b/Completion/Zsh/Command/_vared index aba64880a..e7072ca6d 100644 --- a/Completion/Zsh/Command/_vared +++ b/Completion/Zsh/Command/_vared @@ -10,5 +10,7 @@ _arguments -s -A "-*" \ '-f+[specify finish widget]:widget:_widgets' \ '-h[allow access to history]' \ '-e[exit on EOF (^D)]' \ + '-M+[specify keymap to link to main]:keymap:compadd -a keymaps' \ + '-m+[specify keymap to link to vicmd]:keymap:compadd -a keymaps' \ '1:parameter spec:_vars' -- cgit v1.2.3 From 32cd93bcb04278a6a9c9d2e0af3e1d025841c6d4 Mon Sep 17 00:00:00 2001 From: dana Date: Mon, 30 Dec 2024 20:10:26 -0600 Subject: unposted: _zparseopts: update per workers/53260 --- ChangeLog | 5 +++++ Completion/Zsh/Command/_zparseopts | 2 ++ 2 files changed, 7 insertions(+) (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index 9a40cae5e..cd29452a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2025-01-02 dana + + * unposted: Completion/Zsh/Command/_zparseopts: update + completion per workers/53260 + 2024-12-26 dana * 53260: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c, diff --git a/Completion/Zsh/Command/_zparseopts b/Completion/Zsh/Command/_zparseopts index e13a91081..ae81937c1 100644 --- a/Completion/Zsh/Command/_zparseopts +++ b/Completion/Zsh/Command/_zparseopts @@ -10,8 +10,10 @@ _arguments -A '-*' : \ '-D[remove parsed options from positional parameters]' \ "-E[don't stop parsing at first parameter not described by specs]" \ '-F[abort parsing and print error at first option-like parameter not described by specs]' \ + '-G[enable GNU-style parsing]' \ '-K[preserve contents of arrays/associations when specs are not matched]' \ '-M[enable mapping among equivalent options with opt1=opt2 spec form]' \ + '-v+[specify array from which to parse options]:array:_parameters -g "*array*"' \ '(-)-[end zparseopts options; specs follow]' \ '*: :->spec' \ && ret=0 -- cgit v1.2.3 From 13417c27014aee0bb201988ecd81421f2e987c8c Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Thu, 30 Jan 2025 12:53:48 +0100 Subject: 53338: complete typeset -n option --- ChangeLog | 2 ++ Completion/Zsh/Command/_typeset | 61 +++++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 27 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index 3ddb16ace..27ae19b06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2025-01-30 Oliver Kiddle + * 53338: Completion/Zsh/Command/_typeset: complete typeset -n option + * 53337: Doc/Zsh/mod_ksh93.yo, Src/Modules/ksh93.c: allow nameref -p * 53336: Doc/Makefile.in, Etc/Makefile.in: diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index 058842378..59ee8ec0a 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -1,59 +1,61 @@ -#compdef autoload declare export functions integer float local readonly typeset +#compdef autoload declare export functions integer float local nameref private readonly typeset local expl state state_descr line func i use curcontext="$curcontext" ret=1 local fopts="-f -k -z +k +z" -local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -r -x" +local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -n -r -x" local -A allargs opt_args local -a args allargs=( - A "($fopts -E -F -L -R -T -U -Z -a -i -m)-A[specify that arguments refer to associative arrays]" - E "($fopts -A -F -L -R -T -U -Z -a -i -m)-E[floating point, use engineering notation on output]" - F "($fopts -A -E -L -R -T -U -Z -a -i -m)-F[floating point, use fixed point decimal on output]" - L "($fopts -A -E -F -i)-L+[left justify and remove leading blanks from value]:width" - R "($fopts -A -E -F -i)-R+[right justify and fill with leading blanks]:width" - T "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array or trace function]" + A "($fopts -E -F -L -R -T -U -Z -a -i -m -n)-A[specify that arguments refer to associative arrays]" + E "($fopts -A -F -L -R -T -U -Z -a -i -m -n)-E[floating point, use engineering notation on output]" + F "($fopts -A -E -L -R -T -U -Z -a -i -m -n)-F[floating point, use fixed point decimal on output]" + L "($fopts -A -E -F -i -n)-L+[left justify and remove leading blanks from value]:width" + R "($fopts -A -E -F -i -n)-R+[right justify and fill with leading blanks]:width" + T "($fopts -A -E -F -a -g -h -i -l -m -n -t)-T[tie scalar to array or trace function]" Tf "($popts -t)-T[trace execution of this function only]" - Tp "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array]" + Tp "($fopts -A -E -F -a -g -h -i -l -m -n -t)-T[tie scalar to array]" U '(-A -E -F -i)-U[keep array values unique and suppress alias expansion for functions]' Uf '-U[suppress alias expansion for functions]' - Up '(-E -F -i)-+U[keep array values unique]' + Up '(-E -F -i -n)-+U[keep array values unique]' X '+X[immediately autoload function]' - Z "($fopts -A -E -F -i)-Z+[right justify and fill with leading zeros]:width" - a "($fopts -A -E -F -T -i)-a[specify that arguments refer to arrays]" + Z "($fopts -A -E -F -i -n)-Z+[right justify and fill with leading zeros]:width" + a "($fopts -A -E -F -T -i +i)-a[specify that arguments refer to arrays]" df "-d[default absolute path autoload to fpath]" f "($popts)-f[specify that arguments refer to functions]" - g "($fopts -T)-+g[do not restrict parameter to local scope]" - h "($fopts -T)-+h[hide specialness of parameter]" - H "($fopts -T)-+H[hide value of parameter in listings]" - i "($fopts -A -E -F -T)-+i[represent internally as an integer]" + g "($fopts -T)-+g[don't restrict parameter to local scope]" + h "($fopts -T -n)-+h[hide specialness of parameter]" + H "($fopts -T -n)-+H[hide value of parameter in listings]" + i "($fopts -A -E -F -T -n)-+i[represent internally as an integer]" k "($popts -w -z)-+k[mark function for ksh-style autoloading]" - l "($popts -T)-l[convert the value to lowercase]" - m '(-A -E -F -T -i)-m[treat arguments as patterns]' + l "($popts -T -n)-l[convert the value to lowercase]" + m '(-A -E -F -T -i -n)-m[treat arguments as patterns]' + n "($fopts -A -E -F -H +H -L -R -T -U +U -Z -a -i +i -h +h -l -m -t +t -x +x)-n[make parameter a reference to another parameter]" p '-p+[output parameters in form of calls to typeset]::option:((1\:multi-line\ output\ of\ arrays))' r '(-f)-+r[mark parameters as readonly]' rf '-r[remember autoload path]' Rf '-R[remember autoload path, error if not found]' - t '(-T)-+t[tag parameters and turn on execution tracing for functions]' + t '(-T -n)-+t[tag parameters and turn on execution tracing for functions]' tf '(-T)-+t[turn on execution tracing for functions]' - tp '(-T)-+t[tag parameters]' + tp '(-T -n)-+t[tag parameters]' u '-u[convert the value to uppercase or mark function for autoloading]' uf '-u[mark function for autoloadling]' up '-u[convert the value to uppercase]' w '(-k -z)-w[specify that arguments refer to files compiled with zcompile]' W '-+W[turn on WARN_NESTED_VAR for function]' - x "($fopts)-+x[export parameter]" + x "($fopts -n)-+x[export parameter]" z "($popts -k -w)-+z[mark function for zsh-style autoloading]" ) +allargs[rp]="$allargs[r]" -use="AEFHLRTUZafghiklmprtuxz" +use="AEFHLRTUZafghiklmnprtuxz" case ${service} in autoload) use="URTXdkrtwz" func=f ;; - float) use="EFHghlprtux";; + float) use="EFHghlprtux" func=p ;; functions) use="UkmTtuzW" func=f @@ -66,15 +68,20 @@ case ${service} in ;; integer) use="Hghilprtux" + func=p allargs[i]='-i+[specify arithmetic base for output]:: :_guard "[0-9]#" base' \ ;; - readonly) use="${use/r/}" ;; - local) use="${use//[fgkz]/}" ;; - export) use="${use//[fgkxz]/}" ;; + readonly) use="${use//[nr]/}" func=p ;; + local) use="${use//[fgkpz]/}" func=p ;; + export) use="${use//[fgknxz]/}" func=p ;; + nameref) use="gpur" func=p ;; + private) use="${use//[fgkpzT]/}" func=p ;; esac -[[ -z "${words[(r)-*[aA]*]}" ]] || func=p +[[ -z "${words[(r)-*[AEFHLRTZaghinrx]*]}" ]] || func=p [[ -z "${words[(r)-*f*]}" ]] || func=f +[[ $service = nameref || -n "${words[(r)-*n*]}" ]] && + allargs[up]='-u[reference the upper (calling function) scope]' # This function uses whacky features of _arguments which means we # need to look for options to the command beforehand. -- cgit v1.2.3 From 2e08ea1aef9d47b2919d7e5bd2cb6bb01c8029fc Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Thu, 13 Feb 2025 23:11:09 +0100 Subject: 53358: adapt completion to reflect 53348 and extend exclusion lists to cover more + options --- ChangeLog | 5 ++++ Completion/Zsh/Command/_typeset | 56 ++++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 28 deletions(-) (limited to 'Completion/Zsh/Command') diff --git a/ChangeLog b/ChangeLog index cc1caff26..990509ae1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2025-02-13 Oliver Kiddle + + * 53358: Completion/Zsh/Command/_typeset: adapt completion to + reflect 53348 and extend exclusion lists to cover more + options + 2025-02-12 Bart Schaefer * 53360: Src/Zle/complist.c: domenuselect() fails if the previous diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index 59ee8ec0a..1952a6338 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -2,48 +2,48 @@ local expl state state_descr line func i use curcontext="$curcontext" ret=1 local fopts="-f -k -z +k +z" -local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -n -r -x" +local popts="-A +A -E +E -F +F -L +L -R +R -T -Z +Z -a +a -g +g -h +h -H +H -i +i -l +l -n +n -r +r -x +x" local -A allargs opt_args local -a args allargs=( - A "($fopts -E -F -L -R -T -U -Z -a -i -m -n)-A[specify that arguments refer to associative arrays]" - E "($fopts -A -F -L -R -T -U -Z -a -i -m -n)-E[floating point, use engineering notation on output]" - F "($fopts -A -E -L -R -T -U -Z -a -i -m -n)-F[floating point, use fixed point decimal on output]" - L "($fopts -A -E -F -i -n)-L+[left justify and remove leading blanks from value]:width" - R "($fopts -A -E -F -i -n)-R+[right justify and fill with leading blanks]:width" - T "($fopts -A -E -F -a -g -h -i -l -m -n -t)-T[tie scalar to array or trace function]" - Tf "($popts -t)-T[trace execution of this function only]" - Tp "($fopts -A -E -F -a -g -h -i -l -m -n -t)-T[tie scalar to array]" - U '(-A -E -F -i)-U[keep array values unique and suppress alias expansion for functions]' + A "($fopts -A +A -E +E -F +F -L +L -R +R -T -U +U -Z +Z -a +a -i +i -m +m -n +n)-+A[specify that arguments refer to associative arrays]" + E "($fopts -A +A -E +E -F +F -L +L -R +R -T -U +U -Z +Z -a +a -i +i -m +m -n +n)-+E[floating point, use engineering notation on output]" + F "($fopts -A +A -E +E -F +F -L +L -R +R -T -U +U -Z +Z -a +a -i +i -m +m -n +n)-+F[floating point, use fixed point decimal on output]" + L "($fopts -A +A -E +E -F +F -L +L -R +R -i -n +n)-+L+[left justify and remove leading blanks from value]:width" + R "($fopts -A +A -E +E -F +F -L +L -R +R -i -n +n)-+R+[right justify and fill with leading blanks]:width" + T "($fopts -A +A -E -F -a +a -g -h -i -l +l -m +m -n +n -t)-T[tie scalar to array or trace function]" + Tf "($popts -t +t -T +T)-+T[trace execution of this function only]" + Tp "($fopts -A +A -E +E -F +F -a +a -g -h -i -l +l -m +m -n +n -t)-T[tie scalar to array]" + U '(-A +A -E +E -F +F -i)-U[keep array values unique and suppress alias expansion for functions]' Uf '-U[suppress alias expansion for functions]' - Up '(-E -F -i -n)-+U[keep array values unique]' + Up '(-E +E -F +F -i -n +n)-+U[keep array values unique]' X '+X[immediately autoload function]' - Z "($fopts -A -E -F -i -n)-Z+[right justify and fill with leading zeros]:width" - a "($fopts -A -E -F -T -i +i)-a[specify that arguments refer to arrays]" + Z "($fopts -A +A -E +E -F +F -Z +Z -i -n +n)-+Z+[right justify and fill with leading zeros]:width" + a "($fopts -A +A -E +E -F +F -T -i +i)-+a[specify that arguments refer to arrays]" df "-d[default absolute path autoload to fpath]" - f "($popts)-f[specify that arguments refer to functions]" + f "($popts -f +f)-+f[specify that arguments refer to functions]" g "($fopts -T)-+g[don't restrict parameter to local scope]" - h "($fopts -T -n)-+h[hide specialness of parameter]" - H "($fopts -T -n)-+H[hide value of parameter in listings]" - i "($fopts -A -E -F -T -n)-+i[represent internally as an integer]" + h "($fopts -T -n +n)-+h[hide specialness of parameter]" + H "($fopts -T)-+H[hide value of parameter in listings]" + i "($fopts -A +A -E +E -F +F -T -n +n)-+i[represent internally as an integer]" k "($popts -w -z)-+k[mark function for ksh-style autoloading]" - l "($popts -T -n)-l[convert the value to lowercase]" - m '(-A -E -F -T -i -n)-m[treat arguments as patterns]' - n "($fopts -A -E -F -H +H -L -R -T -U +U -Z -a -i +i -h +h -l -m -t +t -x +x)-n[make parameter a reference to another parameter]" + l "($popts -T -n +n)-+l[convert the value to lowercase]" + m '(-A +A -E +E -F +F -T -i -n)-+m[treat arguments as patterns]' + n "($fopts -A +A -E +E -F +F -L -R -T -U +U -Z +Z -a +a -i +i -h +h -l +l -m +m -t +t -x +x)-+n[make parameter a reference to another parameter]" p '-p+[output parameters in form of calls to typeset]::option:((1\:multi-line\ output\ of\ arrays))' - r '(-f)-+r[mark parameters as readonly]' + r '(-f -r +r)-+r[mark parameters as readonly]' rf '-r[remember autoload path]' Rf '-R[remember autoload path, error if not found]' - t '(-T -n)-+t[tag parameters and turn on execution tracing for functions]' - tf '(-T)-+t[turn on execution tracing for functions]' - tp '(-T -n)-+t[tag parameters]' + t '(-T -n +n)-+t[tag parameters and turn on execution tracing for functions]' + tf '(-t +t -T +T)-+t[turn on execution tracing for functions]' + tp '(-T -n +n)-+t[tag parameters]' u '-u[convert the value to uppercase or mark function for autoloading]' uf '-u[mark function for autoloadling]' - up '-u[convert the value to uppercase]' + up '(-u +u)-+u[convert the value to uppercase]' w '(-k -z)-w[specify that arguments refer to files compiled with zcompile]' W '-+W[turn on WARN_NESTED_VAR for function]' - x "($fopts -n)-+x[export parameter]" + x "($fopts -n +n)-+x[export parameter]" z "($popts -k -w)-+z[mark function for zsh-style autoloading]" ) allargs[rp]="$allargs[r]" @@ -60,8 +60,8 @@ case ${service} in use="UkmTtuzW" func=f args=( - '(-k -t -T -u -U -W -x -z -M +M +k +t +W +z)-+M[define mathematical function]' - '(-k -m -t -T -u -U -W -x -z +M +k +t +W +z)-s[define mathematical function that takes a string argument]' + '(-k -t -T +T -u -U -W -x -z -M +M +k +t +W +z)-+M[define mathematical function]' + '(-k -m +m -t -T +T -u -U -W -x -z +M +k +t +W +z)-s[define mathematical function that takes a string argument]' '(-M)-x+[specify spaces to use for indentation]:spaces' '(-* +*)-c[copy shell function to another name]:old name:_functions:new name:_functions' ) -- cgit v1.2.3 From e19cfe7caca143e66bd57acef43f3e64f7992d7b Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 23 Dec 2022 14:27:35 +0100 Subject: _typeset: fix typo --- Completion/Zsh/Command/_typeset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Completion/Zsh/Command') diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index 1952a6338..99b9e7e0d 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -39,7 +39,7 @@ allargs=( tf '(-t +t -T +T)-+t[turn on execution tracing for functions]' tp '(-T -n +n)-+t[tag parameters]' u '-u[convert the value to uppercase or mark function for autoloading]' - uf '-u[mark function for autoloadling]' + uf '-u[mark function for autoloading]' up '(-u +u)-+u[convert the value to uppercase]' w '(-k -z)-w[specify that arguments refer to files compiled with zcompile]' W '-+W[turn on WARN_NESTED_VAR for function]' -- cgit v1.2.3