From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gatech.edu (gatech.edu [130.207.244.244]) by werple.net.au (8.7/8.7) with SMTP id WAA14547 for ; Wed, 18 Oct 1995 22:59:48 +1000 (EST) Received: from euclid (euclid.skiles.gatech.edu) by gatech.edu with SMTP id AA01005 (5.65c/Gatech-10.0-IDA for ); Wed, 18 Oct 1995 08:51:14 -0400 Received: by euclid (5.x/SMI-SVR4) id AA04770; Wed, 18 Oct 1995 08:50:01 -0400 Resent-Date: Thu, 19 Oct 1995 01:50:48 +1300 Old-Return-Path: From: Dave Sainty Message-Id: <199510181250.BAA19191@lido.comp.vuw.ac.nz> To: zsh-workers@math.gatech.edu Cc: dave@Comp.VUW.AC.NZ Subject: Re: "Watch" function? In-Reply-To: Your message of "Wed, 18 Oct 1995 01:24:38 EDT." <9510180524.AA24737@redwood.skiles.gatech.edu> X-Face: /B9VTI#fcP.}X/h^;-~C,RyvcjB8gD' s!52iF{}"OR9bmoP Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/478 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Richard Coleman writes: > > Instead of/in addition to being able to specify a format string for the > > "watch" facility, how hard would it be to have a special function which, if > > defined, would be called whenever the "watch" facility "saw" someone > > login/logout? (Akin to precmd(), periodic(), chpwd(), etc.) > > I meant to reply to this earlier but got sidetracked. Having zsh execute > a shell function at this point is easy. The hard part is passing all the > information that you can access in WATCHFMT to this shell function. We > would probably have to create more special parameters to do this. I'm > not sure if it is worth it. I've been thinking about this too. The obvious solution is to pass the data in in $1 etc, but this is perhaps a little ugly. Another possibility is to define local variables for the duration of the call, with meaningful names for the parameters being passed in. A little nicer, although I never found "magically appearing variables" very clean.... Perhaps a builtin to return system status. This probably sounds like the most work, but it's perhaps (???) cleaner than the above two... eg. The default "watch" function could simply contain: echo "`zshstat user` has `zshstat action` on `zshstat tty` from `zshstat host`" >&2 Or, for the sake of more efficient default functions: zshstat %user has %action on %tty from %host >&2 This has the advantage of lazy evaluation of the information for WATCHFMT, TIMEFMT, whatever, plus _naming_ the data, instead of indexing the parameters, plus fitting cleanly in with how you expect the shell to work (less magic), and gets rid of that purpose built code in zsh to handle special cases like WATCHFMT, gets rid of a few more special shell variables. All it adds is this bizarre builtin, the behaviour of which needs to be decided... Dave.