From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <14ec7b180906080958l71642089k6fbe672fd18c9771@mail.gmail.com> Date: Wed, 28 Aug 2013 10:05:14 +0200 Message-ID: From: Rudolf Sykora To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Subject: Re: [9fans] acme: send dot to the stdin of a more complicated command Topicbox-Message-UUID: 752d3132-ead8-11e9-9d60-3106f5b1d025 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 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 >