Hello, I tried to modify Russ' script below to be usable on p9p. I came up with ------------------------------------ #!/usr/local/plan9/bin/rc
if(! ~ $#* 1) { echo 'usage: Run title' >[1=2] exit 1 } id=`{awk -v 'pat='$1 '$6 ~ pat {print $1}' <{9p read acme/index}} if(~ $#id 0) { echo 'no match for pattern' >[1=2] exit 2 } if(! ~ $#id 1) { echo 'ambiguous pattern' >[1=2] exit 3 } if(~ `{wc -w <{9p read acme/$id/rdsel}} 0) { echo 'no command selected' >[1=2] exit 4 } #exec cat <{9p read acme/$id/rdsel} exec /usr/local/plan9/bin/rc <{9p read acme/$id/rdsel} ------------------------------------ but the last line doesn't really do what I want, yielding the error: Run: exit 1 rc: /dev/fd/5:2: token EOF: syntax error can anybody help me with what is wrong? The commented-out line with cat prints correctly what I have selected in the other window (see the description of the original script), e.g. >awk '{print $2}' Thank you! Ruda On 8 June 2009 20:15, Russ Cox <r...@swtch.com> wrote: >> well, though an inspiring idea, it doesn't sound to be much practical: >> 1) I usually have a special window in which I have many commands. I >> then select the one needed and chord it to the appropriate window >> (i.e. I don't use the whole contents of a window). >> 2) sometimes I have more such windows. > > This is an interesting usage model. I've never seen it before. > The power of acme is that you can extend it with external > programs. The script below implements this usage; I called it Run. > You can type and select your command in one window, with a name matching > pattern, and then in the other window's tag execute >Run pattern. > Run finds the window with a title matching pattern, pulls out the > selected text, and runs it through rc. > > See http://swtch.com/~rsc/acme-Run.png for an illustration. > > Russ > > > #!/bin/rc > > if(! ~ $#* 1) { > echo 'usage: Run title' >[1=2] > exit usage > } > > id=`{awk -v 'pat='$1 '$6 ~ pat {print $1}' /mnt/wsys/index} > if(~ $#id 0) { > echo 'no match for pattern' >[1=2] > exit none > } > if(! ~ $#id 1) { > echo 'ambiguous pattern' >[1=2] > exit ambiguous > } > if(~ `{wc -w /mnt/wsys/$id/rdsel} 0) { > echo 'no command selected' >[1=2] > exit missing > } > exec rc /mnt/wsys/$id/rdsel >