Subject: Streaming sam.

From: Alan Watson <[email-masked]>
Date: Fri, 4 Dec 1992 11:40:32 -0500

I have a recollection that a streaming version of sam a la sed is
mentioned somewhere in the sam documentation, but I cannot find this
reference now.

Was this ever implemented, and what was it's syntax and semantics?
I'm using the following (the error handling of which might be better),
but I wonder if there is a precedent to follow.  This version doesn't
really stream in the sense that I am used to (meaning set up some
commands and then stream the entire file past the commands), but it is
more flexible.  For example, to reverse a file one can use:

	; ssam ',x m0' <foo

Alan.

; cat $home/bin/ssam
#! /usr/users/alan/bin/rc

if ( ~ $#* 0) {
  echo >[1=2] Usage: ssam commands ...
  exit 1
}

FIFO=/usr/tmp/ssam.$pid.rd
mkfifo $FIFO

{
  echo 'r '$FIFO
  while ( ! ~ $#* 0 ) {
    echo $1
    shift
  }
  echo ',p'
} | sam -d >[2=] &

cat >$FIFO

wait $apid

rm -f $FIFO

exit 0

# end-of-file

---

From: Alan Watson <[email-masked]>
Date: Fri, 4 Dec 1992 11:44:20 -0500

Sigh.  The reverse trick doesn't work.  It's been a bad month.  Try:

	; ssam ',x m$' <foo

---

From: Alan Watson <[email-masked]>
Date: Fri, 4 Dec 1992 12:57:35 -0500

Scrub that.  Try the following awful hack:

	; cat rev
	,x/\\/ i/\\/
	,x/\// i/\\/
	,x i/0i\//
	,x s/\n/\\n\/\n/
	$a/,p\n/
	,|sam -d
	; ifs = $nl ssam `{ cat rev } <rev  >rev2
	; ifs = $nl ssam `{ cat rev } <rev2 >rev3
	; diff rev rev3
	;

A free email message to anyone who can do better.  I think I'd better
lie down.

---

From: [email-masked] (Byron Rakitzis)
Date: Fri, 4 Dec 1992 14:10:06 -0500

I've written a very basic stream sam, more of a toy than anything else,
just to see how it would feel. I think there are some basic problems
with the command language as applied to streams that the idea doesn't
work.

I don't want to duke it out on the list; I don't have time. My source
is available to anyone who cares. It's a couple of hundred lines of
C and implements x, y, a, c, and i. I use Henry's regexp package with
hacks to make $ and ^ work on newlines, not just beginning- and end-of-
string.