rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* biff?
@ 1991-06-28 20:19 Byron Rakitzis
  1991-06-28 20:30 ` biff? Mark-Jason Dominus
  0 siblings, 1 reply; 2+ messages in thread
From: Byron Rakitzis @ 1991-06-28 20:19 UTC (permalink / raw)
  To: rc


I got sick of xbiff; both the annoying beep, and the ugly icon,
and I decided to replace it with the sweeter sound of a bell-
chime that I have for my sparcstation. Here's the rc script
that does the job:

#!/bin/rc

if (! ~ `{arch -k} sun4c)	# Are we on a sparcstation?
	exit

exec >[2] /dev/null		# Throw away errors from ls

mail=/usr/spool/mail/`whoami

fn getsize {			# Get the size of $mail in bytes
	size = `{ls -l $mail}
	size = $size(4)
	if (~ $#size 0)		# No output from ls?
		size = 0
	$1 = $size
}

fn ring {
	play -v 30 $h/lib/doorbell.au
	echo Mail received at `date > /dev/console
}

old = 0

while () {
	getsize new
	if (test $new -gt $old) {
		ring
		old = $new
	} else if (test $old -gt $new) {
		old = $new
	}
	sleep 10
}

There's not much here that's rc specific, except that I don't have
to call sed or awk in order to figure out the size of $mail.

I thought it was cute...


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: biff?
  1991-06-28 20:19 biff? Byron Rakitzis
@ 1991-06-28 20:30 ` Mark-Jason Dominus
  0 siblings, 0 replies; 2+ messages in thread
From: Mark-Jason Dominus @ 1991-06-28 20:30 UTC (permalink / raw)
  To: Byron Rakitzis; +Cc: mjd, rc


> fn getsize {			# Get the size of $mail in bytes
> 	size = `{ls -l $mail}
> 	size = $size(4)
> 	if (~ $#size 0)		# No output from ls?
> 		size = 0
> 	$1 = $size
> }

Does this work at all?  On my machine $size(4) is `mjd', because there's
a double space between the permissions and the link count except when
the number of links exceeds 9.

-rw-------  1 mjd             0 Jun 28 16:24 /var/spool/mail/mjd

In fact, it's very difficult to get the size, because it's $size(17),
unless the size exceeds 9 bytes, in which case it's $size(16),  unless
the size exceeds 99 bytes, inwhich case it's $size(15)...

Who was it who said that the $ifs behavior was doing the right thing?


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1991-06-28 20:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-06-28 20:19 biff? Byron Rakitzis
1991-06-28 20:30 ` biff? Mark-Jason Dominus

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).