zsh-users
 help / color / mirror / code / Atom feed
From: Deborah Ariel Pickett <debbiep@cs.monash.edu.au>
To: luomat+zsh+users@luomat.peak.org (Timothy J Luoma)
Cc: zsh-users@math.gatech.edu
Subject: Re: showing 'talk' status in PROMPT
Date: Tue, 28 Oct 1997 12:28:13 +1100 (EST)	[thread overview]
Message-ID: <199710280128.MAA26043@molly.cs.monash.edu.au> (raw)
In-Reply-To: <199710270443.XAA17820@luomat.peak.org> from "Timothy J Luoma" at Oct 26, 97 11:43:35 pm

> I am using this to let me know if I have turned off messages on my terminal:
> mesg () {
...
> }
> Does anyone see any problems with this, or have a better way to do this?

I do this by rather a different way.  Every so often, I check the status
of my TTY to see whether it has write access granted to others.  I
figure that I don't type 'mesg' very often, so checking every minute or
so isn't much of a performance loss.

I wanted to be able to just do something like 'mesg >/dev/null' to use
the exit status of mesg to determing if messages are on or not without
cluttering up my screen with "is n" or "is y".  But the writers of mesg
on Ultrix in all their wisdom, printed the message to stderr, and also
used stderr as the tty to check.  So it just couldn't work.

I finally wrote a tiny perl script to do it:

#!/usr/monash/bin/perl
# Return y or n based on whether others can write to our tty.
# usage: mesg-status $TTY
if ((stat($ARGV[0]))[2] & 022)
{
  print "y\n";
}
else
{
  print "n\n";
}

so I just invoke this every now and again and insert it into my prompt
in the usual ways.

Granted, it isn't as efficient as the rewriting of the mesg function,
but I suppose it makes up for that by always being correct, if, say,
something else tries to change the status of my tty.

-- 
Debbie Pickett  http://www.cs.monash.edu.au/~debbiep/  tlm@yoyo.cc.monash.edu.au
"Long and wide, eternity from side to side, lead me through the rapids, guide me
 to the shore. There's a place that's far beyond this time and space, when each
  of us comes face to face with something more." - _Siren Song_, Alan Parsons


      parent reply	other threads:[~1997-10-28  1:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-27  4:43 Timothy J Luoma
1997-10-27  8:52 ` Peter Stephenson
1997-10-27 17:18   ` Timothy J Luoma
1997-10-27 17:21   ` Bart Schaefer
1997-10-27 18:13     ` Andrew Main
1997-10-28  1:28 ` Deborah Ariel Pickett [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=199710280128.MAA26043@molly.cs.monash.edu.au \
    --to=debbiep@cs.monash.edu.au \
    --cc=luomat+zsh+users@luomat.peak.org \
    --cc=tlm@yoyo.cc.monash.edu.au \
    --cc=zsh-users@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).