On Thu Dec  3 12:49:01 EST 2009, mauricio.antu...@gmail.com wrote:
> I would like to write a script that takes text from standard
> input, lets the user edit it with 'sam -d' and then prints it to
> standard output.
> 
> Do you think that makes sense? After all, 'sam -d' needs standard
> input and output in order to edit anything.

i don't think ssam is what you want, since you want interactive
editing.  i think what you want is a modified ssam that reopens
the console.  the reason for this is to seperate the editing from
the command stream. something like (for plan 9, run once)

#!/bin/rc
tmp=()
fn sighup sigint sigexit{
        rm -f $tmp
}
tmp = /tmp/esam.$pid
cat $* > $tmp
tty = /dev/cons
sam -d $tmp <>[0]$tty >[1=0]
cat $tmp
exit ''

or for linux (untested)

#!/bin/rc
tmp=()
fn sighup sigint sigexit{
        rm -f $tmp
}
if(~ $#TMPDIR 0)
        TMPDIR=/tmp
tmp=$TMPDIR/ssam.tmp.$USER.$pid
cat $* >$tmp
tty = `{tty}
sam -d $tmp <>[0]$tty >[1=0]
cat $tmp

- erik

Reply via email to