summaryrefslogtreecommitdiff
path: root/rc/bin/ssam
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-10-24 00:54:01 +0200
committercinap_lenrek <cinap_lenrek@centraldogma>2011-10-24 00:54:01 +0200
commit9d8657023ecb154ca8ad3ab53fde5ac54440e42e (patch)
treecd075474a1d1e1bb09e1d922bea21ed02a4302fe /rc/bin/ssam
parentf5fe39ad7afa9b761821178ba57f28cea03396b8 (diff)
parentda81fd83cef21d07ef613535867e97ab77ed09a8 (diff)
merge
Diffstat (limited to 'rc/bin/ssam')
-rw-r--r--rc/bin/ssam41
1 files changed, 41 insertions, 0 deletions
diff --git a/rc/bin/ssam b/rc/bin/ssam
new file mode 100644
index 000000000..917a34f71
--- /dev/null
+++ b/rc/bin/ssam
@@ -0,0 +1,41 @@
+#!/bin/rc
+# ssam - stream interface to sam
+
+flagfmt='n,e script,f sfile'
+args='[ file ... ]'
+if(! ifs=() eval `{aux/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