aboutsummaryrefslogtreecommitdiff
path: root/bin/ssam
blob: 7b479ea5a9099d610fc8b7029a401e560228cf53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/local/plan9/bin/rc
# ssam - stream interface to sam

flagfmt='n,e script,f sfile'
args='[ file ... ]'
if(! ifs=() eval `{getflags $*}){
	usage
	exit usage
}

if(~ $#flage 0 && ~ $#flagf 0) {
	if(~ $#* 0) {
		usage
		exit usage
	}
	flage=$1
	shift
}

if(~ $#TMPDIR 0)
	TMPDIR=/tmp
tmp=$TMPDIR/ssam.tmp.$USER.$pid
cat $* >$tmp

{
	# select entire file
	echo ',{'
	echo k
	echo '}'
	echo 0k

	# run scripts, print
	if(! ~ $#flagf 0)
		cat $flagf
	if(! ~ $#flage 0)
		echo $flage
	if(~ $#flagn 0)
		echo ,
} | sam -d $tmp >[2]/dev/null

rm -f $tmp