plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 0a1990b94af2ac34aa63c0ed2b082aa8d15c3030
parent 113867b836eaa85215e4b2ece5ccf612f34c3e03
Author: Jason Catena <jason.catena@gmail.com>
Date:   Wed, 30 Sep 2009 11:01:45 -0700

ssam(1): new command - not just manual

Diffstat:
Abin/ssam | 41+++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+), 0 deletions(-)

diff --git a/bin/ssam b/bin/ssam @@ -0,0 +1,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