zsh-workers
 help / color / mirror / code / Atom feed
From: Hrvoje Niksic <hniksic@srce.hr>
To: zsh-workers@math.gatech.edu (ZSH Workers Mailing List)
Subject: A simpler watch log
Date: 11 Jun 1996 17:55:32 +0200	[thread overview]
Message-ID: <kig3f42xrm3.fsf@jagor.srce.hr> (raw)

A friend of mine (joe@fly.cc.fer.hr) has suggested that the log
command should accept a parameter to tell it to print the log in a
simple format, like the 'users' command.

I have implemented a '-u' option to the log builtin which makes it
print only the username on each line. It adds an argument to the
dowatch(), which, if set, means "simple" watch, which in turns sets
the fmt to "%n".

This is not completely compatible with 'users' output, since each
username is on a separate line. A little more tweaking by someone who
knows more about watch.c could result in dowatch() not calling
watchlog() at all, if simple is set.

Here is the patch:
*** watch.c.orig	Tue Jun 11 17:46:28 1996
--- watch.c	Tue Jun 11 17:18:37 1996
***************
*** 374,380 ****
  
  /**/
  void
! dowatch(void)
  {
      FILE *in;
      STRUCT_UTMP *utab, *uptr, *wptr;
--- 374,380 ----
  
  /**/
  void
! dowatch(int simple_format)
  {
      FILE *in;
      STRUCT_UTMP *utab, *uptr, *wptr;
***************
*** 385,391 ****
      int uct, wct;
  
      s = watch;
!     if (!(fmt = getsparam("WATCHFMT")))
  	fmt = DEFAULT_WATCHFMT;
  
      holdintr();
--- 385,393 ----
      int uct, wct;
  
      s = watch;
!     if (simple_format)
!     	fmt = SIMPLE_WATCHFMT;
!     else if (!(fmt = getsparam("WATCHFMT")))
  	fmt = DEFAULT_WATCHFMT;
  
      holdintr();
***************
*** 460,466 ****
      wtab = (STRUCT_UTMP *)zalloc(1);
      wtabsz = 0;
      lastutmpcheck = 0;
!     dowatch();
      return 0;
  }
  
--- 462,471 ----
      wtab = (STRUCT_UTMP *)zalloc(1);
      wtabsz = 0;
      lastutmpcheck = 0;
!     if (ops['u'])
!     	dowatch(1);
!     else
!     	dowatch(0);
      return 0;
  }
  
*** hashtable.h.orig	Tue Jun 11 17:46:49 1996
--- hashtable.h	Tue Jun 11 17:35:32 1996
***************
*** 282,288 ****
      {NULL, "let", 0, bin_let, 1, -1, 0, NULL, NULL},
      {NULL, "limit", 0, bin_limit, 0, -1, 0, "sh", NULL},
      {NULL, "local", BINF_TYPEOPTS | BINF_MAGICEQUALS, bin_typeset, 0, -1, 0, "LRUZilrtu", NULL},
!     {NULL, "log", 0, bin_log, 0, 0, 0, NULL, NULL},
      {NULL, "logout", 0, bin_break, 0, 1, BIN_LOGOUT, NULL, NULL},
  
  #if defined(ZSH_MEM) & defined(ZSH_MEM_DEBUG)
--- 282,288 ----
      {NULL, "let", 0, bin_let, 1, -1, 0, NULL, NULL},
      {NULL, "limit", 0, bin_limit, 0, -1, 0, "sh", NULL},
      {NULL, "local", BINF_TYPEOPTS | BINF_MAGICEQUALS, bin_typeset, 0, -1, 0, "LRUZilrtu", NULL},
!     {NULL, "log", 0, bin_log, 0, 0, 0, "u", NULL},
      {NULL, "logout", 0, bin_break, 0, 1, BIN_LOGOUT, NULL, NULL},
  
  #if defined(ZSH_MEM) & defined(ZSH_MEM_DEBUG)
*** system.h.orig	Tue Jun 11 17:47:02 1996
--- system.h	Tue Jun 11 17:14:13 1996
***************
*** 305,310 ****
--- 305,312 ----
  # define DEFAULT_WATCHFMT "%n has %a %l."
  #endif
  
+ #define SIMPLE_WATCHFMT "%n"
+ 
  #define DEFAULT_WORDCHARS "*?_-.[]~=/&;!#$%^(){}<>"
  #define DEFAULT_TIMEFMT   "%J  %U user %S system %P cpu %*E total"
  


-- 
hniksic@srce.hr              |  Student of electrical engineering
hniksic@fly.cc.fer.hr        |  University of Zagreb, Croatia
------------------------------------------------------------------
I'm a Lisp variable -- bind me!



                 reply	other threads:[~1996-06-11 16:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=kig3f42xrm3.fsf@jagor.srce.hr \
    --to=hniksic@srce.hr \
    --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).