zsh-workers
 help / color / mirror / code / Atom feed
From: Dave Sainty <David.Sainty@Comp.VUW.AC.NZ>
To: zsh-workers@math.gatech.edu
Cc: dave@Comp.VUW.AC.NZ
Subject: Re: "Watch" function?
Date: Thu, 19 Oct 1995 01:50:48 +1300	[thread overview]
Message-ID: <199510181250.BAA19191@lido.comp.vuw.ac.nz> (raw)
In-Reply-To: Your message of "Wed, 18 Oct 1995 01:24:38 EDT." <9510180524.AA24737@redwood.skiles.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.


      parent reply	other threads:[~1995-10-18 12:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-10-10 19:53 daemonboy
1995-10-10 20:07 ` Dave Sainty
1995-10-18  5:24 ` Richard Coleman
1995-10-18 12:26   ` Zoltan Hidvegi
1995-10-18 12:50   ` Dave Sainty [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199510181250.BAA19191@lido.comp.vuw.ac.nz \
    --to=david.sainty@comp.vuw.ac.nz \
    --cc=dave@Comp.VUW.AC.NZ \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).