sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
From: hc05@summitis.com
To: sam-fans-owner
Subject: Re
Date: Thu, 8 Dec 1994 13:12:18 -0500	[thread overview]
Message-ID: <9412081753.AA17166@cheetah> (raw)
In-Reply-To: <9412081718.AA119815@rexsrvr2.summitis.com> from "sam-fans-owner@hawkwind.utcs.toronto.edu" at Dec 8, 94 12:17:00 pm

>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
beirnek@summitis.com            | ready man, and writing an exact man.
"Untouched by Scandal"          |       -- Francis Bacon
-------------------------------------------------------------------------------



           reply	other threads:[~1994-12-08 21:17 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <9412081718.AA119815@rexsrvr2.summitis.com>]

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=9412081753.AA17166@cheetah \
    --to=hc05@summitis.com \
    /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.
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).