9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Rudolf Sykora <rudolf.sykora@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] acme: send dot to the stdin of a more complicated command
Date: Wed, 28 Aug 2013 10:05:14 +0200	[thread overview]
Message-ID: <CAOEdRO1iP6T9Wh2RQ4f+rk7Ro86YxBEH_uLF63bcUKRq=7uLOw@mail.gmail.com> (raw)
In-Reply-To: <dd6fe68a0906081115i5153e43fqe6fb52619f9854d0@mail.gmail.com>

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 <rsc@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
>



  parent reply	other threads:[~2013-08-28  8:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-08 12:48 Rudolf Sykora
2009-06-08 16:04 ` Lyndon Nerenberg
2009-06-08 16:34   ` Rudolf Sykora
2009-06-08 16:58     ` andrey mirtchovski
2009-06-08 17:30       ` Rudolf Sykora
2009-06-08 17:35         ` andrey mirtchovski
2009-06-08 17:45           ` Rudolf Sykora
2009-06-08 17:42         ` yy
2009-06-08 18:15         ` Russ Cox
2009-06-08 18:35           ` Dan Cross
2009-06-08 18:59           ` [9fans] acme: send dot to the stdin of a more complicated Skip Tavakkolian
2009-06-09  8:28           ` [9fans] acme: send dot to the stdin of a more complicated command Rudolf Sykora
2013-08-28  8:05           ` Rudolf Sykora [this message]
2013-08-28 12:13             ` dexen deVries
2013-08-28 12:53               ` Rudolf Sykora
2013-08-28 15:11               ` James A. Robinson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOEdRO1iP6T9Wh2RQ4f+rk7Ro86YxBEH_uLF63bcUKRq=7uLOw@mail.gmail.com' \
    --to=rudolf.sykora@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).