From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32601 invoked from network); 1 Nov 2021 00:06:53 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Nov 2021 00:06:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:Reply-To:Cc: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=2bHvh7Y2uZmEwwFY8n1RQiCMIwLthGNz6jNvU8l8OtY=; b=bcBtNAvw2YJGz2Pmw91tVVerSa 18u5aVS92nVR/A96kvHN8PO/YppoxwSql9hDqprJAXhufCN+qi9mFMN+3Ti++P8hIV5IId2gIs1lC 91GL2pAHGk+5nU91lW1qh93eWrCALN65guDh7kEvZEmz/AOIk8xEGqKNzeWJylRGQDOBs7VgDwm5p SGJFolW4hTaftdYymq0L7yxI4HrpQmkOShF02VRhwiHpUn3iaRNv+soZ1a90EuudJQDP7Sn6URuf7 jlmg3WbGG29jJBM0hCbVq3lwT8SwUQFtalef5gtOCwFK/Z3JawsOuCIufenDle4iil2/CgJMW3tr0 xn9WIKRw==; Received: from authenticated user by zero.zsh.org with local id 1mhKqj-0008sq-6I; Mon, 01 Nov 2021 00:06:53 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mhKqU-0008ah-Lt; Mon, 01 Nov 2021 00:06:38 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.94.2) (envelope-from ) id 1mhKqR-000PlB-Kr for zsh-workers@zsh.org; Mon, 01 Nov 2021 01:06:35 +0100 In-reply-to: <41833-1635545739.955327@NiDy.UqMC.wWcd> From: Oliver Kiddle References: <41833-1635545739.955327@NiDy.UqMC.wWcd> To: Zsh workers Subject: Re: PATCH: separate watch/log functionality out into a module MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <99023.1635725195.1@hydra> Date: Mon, 01 Nov 2021 01:06:35 +0100 Message-ID: <99024-1635725195.643285@RFFV.JZgp.GVTq> X-Seq: 49539 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: I wrote: > This patch extracts the functionality out into a zsh/watch module. The following is a corresponding documentation patch. This only moves existing documentation to come under zshmodules(1) instead of zshparam(1). The moved blocks are not otherwise changed. The autoloading of modules from parameters is not ideal where the parameters come from the environment. If WATCH is in the imported environment it will now print an error that the parameter already exists. I don't think this matters especially for WATCH but this would need dealing with before we could do something similar for $MAIL. For an example with an unpatched zsh, this is not great: options=foo zsh -df zsh: options: attempt to set slice of associative array And unlike for WATCH, that's a fatal error so zsh exits. Oliver diff --git a/Doc/Makefile.in b/Doc/Makefile.in index 5a6a705ff..23e5fc7e2 100644 --- a/Doc/Makefile.in +++ b/Doc/Makefile.in @@ -69,6 +69,7 @@ Zsh/mod_parameter.yo Zsh/mod_pcre.yo Zsh/mod_private.yo \ Zsh/mod_regex.yo Zsh/mod_sched.yo Zsh/mod_socket.yo \ Zsh/mod_stat.yo Zsh/mod_system.yo Zsh/mod_tcp.yo \ Zsh/mod_termcap.yo Zsh/mod_terminfo.yo \ +Zsh/mod_watch.yo \ Zsh/mod_zftp.yo Zsh/mod_zle.yo Zsh/mod_zleparameter.yo \ Zsh/mod_zprof.yo Zsh/mod_zpty.yo Zsh/mod_zselect.yo \ Zsh/mod_zutil.yo diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index ddbcd4363..733d8f185 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -1235,14 +1235,6 @@ Same as tt(typeset), except that the options tt(-g), and tt(-f) are not permitted. In this case the tt(-x) option does not force the use of tt(-g), i.e. exported variables will be local to functions. ) -findex(log) -vindex(watch, use of) -cindex(watching users) -cindex(users, watching) -item(tt(log))( -List all users currently logged in who are affected by -the current setting of the tt(watch) parameter. -) findex(logout) item(tt(logout) [ var(n) ])( Same as tt(exit), except that it only works in a login shell. diff --git a/Doc/Zsh/compat.yo b/Doc/Zsh/compat.yo index 6e4dbcfa4..4d3567d45 100644 --- a/Doc/Zsh/compat.yo +++ b/Doc/Zsh/compat.yo @@ -30,8 +30,7 @@ tt(PROMPT2), tt(PROMPT3), tt(PROMPT4), tt(psvar), -tt(status), -tt(watch). +tt(status). vindex(ENV, use of) The usual zsh startup/shutdown scripts are not executed. Login shells diff --git a/Doc/Zsh/mod_watch.yo b/Doc/Zsh/mod_watch.yo new file mode 100644 index 000000000..4eea89e23 --- /dev/null +++ b/Doc/Zsh/mod_watch.yo @@ -0,0 +1,140 @@ +COMMENT(!MOD!zsh/watch +Reporting of login and logout events. +!MOD!) +The tt(zsh/watch) module can be used to report when specific users log in or +out. This is controlled via the following parameters. + +startitem() +vindex(LOGCHECK) +item(tt(LOGCHECK))( +The interval in seconds between checks for login/logout activity +using the tt(watch) parameter. +) +vindex(watch) +vindex(WATCH) +item(tt(watch) (tt(WATCH) ))( +An array (colon-separated list) of login/logout events to report. + +If it contains the single word `tt(all)', then all login/logout events +are reported. If it contains the single word `tt(notme)', then all +events are reported as with `tt(all)' except tt($USERNAME). + +An entry in this list may consist of a username, +an `tt(@)' followed by a remote hostname, +and a `tt(%)' followed by a line (tty). Any of these may +be a pattern (be sure to quote this during the assignment to +tt(watch) so that it does not immediately perform file generation); +the setting of the tt(EXTENDED_GLOB) option is respected. +Any or all of these components may be present in an entry; +if a login/logout event matches all of them, +it is reported. + +For example, with the tt(EXTENDED_GLOB) option set, the following: + +example(watch=('^(pws|barts)')) + +causes reports for activity associated with any user other than tt(pws) +or tt(barts). +) +vindex(WATCHFMT) +item(tt(WATCHFMT))( +The format of login/logout reports if the tt(watch) parameter is set. +Default is `tt(%n has %a %l from %m)'. +Recognizes the following escape sequences: + +startitem() +item(tt(%n))( +The name of the user that logged in/out. +) +item(tt(%a))( +The observed action, i.e. "logged on" or "logged off". +) +item(tt(%l))( +The line (tty) the user is logged in on. +) +item(tt(%M))( +The full hostname of the remote host. +) +item(tt(%m))( +The hostname up to the first `tt(.)'. If only the +IP address is available or the utmp field contains +the name of an X-windows display, the whole name is printed. + +em(NOTE:) +The `tt(%m)' and `tt(%M)' escapes will work only if there is a host name +field in the utmp on your machine. Otherwise they are +treated as ordinary strings. +) +item(tt(%S) LPAR()tt(%s)RPAR())( +Start (stop) standout mode. +) +item(tt(%U) LPAR()tt(%u)RPAR())( +Start (stop) underline mode. +) +item(tt(%B) LPAR()tt(%b)RPAR())( +Start (stop) boldface mode. +) +xitem(tt(%t)) +item(tt(%@))( +The time, in 12-hour, am/pm format. +) +item(tt(%T))( +The time, in 24-hour format. +) +item(tt(%w))( +The date in `var(day)tt(-)var(dd)' format. +) +item(tt(%W))( +The date in `var(mm)tt(/)var(dd)tt(/)var(yy)' format. +) +item(tt(%D))( +The date in `var(yy)tt(-)var(mm)tt(-)var(dd)' format. +) +item(tt(%D{)var(string)tt(}))( +The date formatted as var(string) using the tt(strftime) function, with +zsh extensions as described by +ifzman(EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\ +ifnzman(noderef(Prompt Expansion)). +) +item(tt(%LPAR())var(x)tt(:)var(true-text)tt(:)var(false-text)tt(RPAR()))( +Specifies a ternary expression. +The character following the var(x) is +arbitrary; the same character is used to separate the text +for the "true" result from that for the "false" result. +Both the separator and the right parenthesis may be escaped +with a backslash. +Ternary expressions may be nested. + +The test character var(x) may be any one of `tt(l)', `tt(n)', `tt(m)' +or `tt(M)', which indicate a `true' result if the corresponding +escape sequence would return a non-empty value; or it may be `tt(a)', +which indicates a `true' result if the watched user has logged in, +or `false' if he has logged out. +Other characters evaluate to neither true nor false; the entire +expression is omitted in this case. + +If the result is `true', then the var(true-text) +is formatted according to the rules above and printed, +and the var(false-text) is skipped. +If `false', the var(true-text) is skipped and the var(false-text) +is formatted and printed. +Either or both of the branches may be empty, but +both separators must be present in any case. +) +enditem() +) +enditem() + +Furthermore, the tt(zsh/watch) module makes available one builtin +command: + +startitem() +findex(log) +vindex(watch, use of) +cindex(watching users) +cindex(users, watching) +item(tt(log))( +List all users currently logged in who are affected by +the current setting of the tt(watch) parameter. +) +enditem() diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index a88e44d4f..1f2f01f55 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -1332,11 +1332,6 @@ most as many lines as given by the absolute value. If set to zero, the shell asks only if the top of the listing would scroll off the screen. ) -vindex(LOGCHECK) -item(tt(LOGCHECK))( -The interval in seconds between checks for login/logout activity -using the tt(watch) parameter. -) vindex(MAIL) item(tt(MAIL))( If this parameter is set and tt(mailpath) is not set, @@ -1670,119 +1665,6 @@ to be interpreted as a file extension. The default is not to append any suffix, thus this parameter should be assigned only when needed and then unset again. ) -vindex(watch) -vindex(WATCH) -item(tt(watch) (tt(WATCH) ))( -An array (colon-separated list) of login/logout events to report. - -If it contains the single word `tt(all)', then all login/logout events -are reported. If it contains the single word `tt(notme)', then all -events are reported as with `tt(all)' except tt($USERNAME). - -An entry in this list may consist of a username, -an `tt(@)' followed by a remote hostname, -and a `tt(%)' followed by a line (tty). Any of these may -be a pattern (be sure to quote this during the assignment to -tt(watch) so that it does not immediately perform file generation); -the setting of the tt(EXTENDED_GLOB) option is respected. -Any or all of these components may be present in an entry; -if a login/logout event matches all of them, -it is reported. - -For example, with the tt(EXTENDED_GLOB) option set, the following: - -example(watch=('^(pws|barts)')) - -causes reports for activity associated with any user other than tt(pws) -or tt(barts). -) -vindex(WATCHFMT) -item(tt(WATCHFMT))( -The format of login/logout reports if the tt(watch) parameter is set. -Default is `tt(%n has %a %l from %m)'. -Recognizes the following escape sequences: - -startitem() -item(tt(%n))( -The name of the user that logged in/out. -) -item(tt(%a))( -The observed action, i.e. "logged on" or "logged off". -) -item(tt(%l))( -The line (tty) the user is logged in on. -) -item(tt(%M))( -The full hostname of the remote host. -) -item(tt(%m))( -The hostname up to the first `tt(.)'. If only the -IP address is available or the utmp field contains -the name of an X-windows display, the whole name is printed. - -em(NOTE:) -The `tt(%m)' and `tt(%M)' escapes will work only if there is a host name -field in the utmp on your machine. Otherwise they are -treated as ordinary strings. -) -item(tt(%S) LPAR()tt(%s)RPAR())( -Start (stop) standout mode. -) -item(tt(%U) LPAR()tt(%u)RPAR())( -Start (stop) underline mode. -) -item(tt(%B) LPAR()tt(%b)RPAR())( -Start (stop) boldface mode. -) -xitem(tt(%t)) -item(tt(%@))( -The time, in 12-hour, am/pm format. -) -item(tt(%T))( -The time, in 24-hour format. -) -item(tt(%w))( -The date in `var(day)tt(-)var(dd)' format. -) -item(tt(%W))( -The date in `var(mm)tt(/)var(dd)tt(/)var(yy)' format. -) -item(tt(%D))( -The date in `var(yy)tt(-)var(mm)tt(-)var(dd)' format. -) -item(tt(%D{)var(string)tt(}))( -The date formatted as var(string) using the tt(strftime) function, with -zsh extensions as described by -ifzman(EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\ -ifnzman(noderef(Prompt Expansion)). -) -item(tt(%LPAR())var(x)tt(:)var(true-text)tt(:)var(false-text)tt(RPAR()))( -Specifies a ternary expression. -The character following the var(x) is -arbitrary; the same character is used to separate the text -for the "true" result from that for the "false" result. -Both the separator and the right parenthesis may be escaped -with a backslash. -Ternary expressions may be nested. - -The test character var(x) may be any one of `tt(l)', `tt(n)', `tt(m)' -or `tt(M)', which indicate a `true' result if the corresponding -escape sequence would return a non-empty value; or it may be `tt(a)', -which indicates a `true' result if the watched user has logged in, -or `false' if he has logged out. -Other characters evaluate to neither true nor false; the entire -expression is omitted in this case. - -If the result is `true', then the var(true-text) -is formatted according to the rules above and printed, -and the var(false-text) is skipped. -If `false', the var(true-text) is skipped and the var(false-text) -is formatted and printed. -Either or both of the branches may be empty, but -both separators must be present in any case. -) -enditem() -) vindex(WORDCHARS) item(tt(WORDCHARS) )( A list of non-alphanumeric characters considered part of a word