Subject: Re

From: [email-masked]
Date: Thu, 8 Dec 1994 13:12:18 -0500

>Greetings.  I use 'mush' as my mail program, and I have my EDITOR environment
>variable set to use sam.  The problem comes when I have a sam running, and
>then I go to read mail. When I edit my file, it cranks up another sam. But
>when that sam quits, it removes the fifo in /tmp that the `B' command uses.
>At that point, I can no longer use `B' to communicate with my orignal sam.
>
>My question is, how do *you* handle this?  Does anyone have a shell script
>that runs B on their temporary mail file such that things stay in sync
>after the file is written back out with sam?

I rewrote B to handle this and it works fairly well.  Its written in perl, but
you are welcome to rewrite it in other shell languages if you like.

Beirne

#!/usr/local/perl

@files = ();

if (@ARGV == 0)
{
	print STDERR "usage: B [-nnnn] files...\n";
	exit 1;
}

$dir = `/bin/pwd`;
chop $dir;
($name) = getpwuid($>);
$pipe = '/tmp/.sam.'.$name.'.'.$ENV{'DISPLAY'};

foreach (@ARGV)
{
	if (m#^/#o)
	{
		push(@files, $_);
	}
	elsif (m#^-#o)
	{
		$line = substr($_, 1);
	}
	else
	{
		push(@files, $dir.'/'.$_);
	}
}

if (defined($ENV{'DISPLAY'}) && -w $pipe)
{
	open(PIPE, '>'.$pipe) || die "Can't open $pipe: $!";
	print PIPE "B ", join(' ', @files), "\n";
	
	print PIPE $line, "\n" if (defined($line));
	close(PIPE);
}
elsif (defined($ENV{'DISPLAY'}))
{
	exec 'sam', @files;	
}
else
{
	$editor = 'vi';
	exec $editor, "+$line", @files;
}

-- 
-------------------------------------------------------------------------------
Beirne Konarski                 | Reading maketh a full man, conference a
[email-masked]            | ready man, and writing an exact man.
"Untouched by Scandal"          |       -- Francis Bacon
-------------------------------------------------------------------------------