plan9fox/rc/bin/ssam
cinap_lenrek 9d8657023e merge
2011-10-24 00:54:01 +02:00

42 lines
539 B
Bash

#!/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