From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Thu, 3 Dec 2009 14:34:37 -0500 To: 9fans@9fans.net Message-ID: <7b20ed61c1b8ecf1d0ee9c766a185837@ladd.quanstro.net> In-Reply-To: <> References: <> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Input/output Topicbox-Message-UUID: a6fc98cc-ead5-11e9-9d60-3106f5b1d025 On Thu Dec 3 12:49:01 EST 2009, mauricio.antunes@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