9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: 9p-st@imu.li (Tristan Plumb)
Subject: [9fans] Making read(1) an rc(1) builtin?
Date: Sun,  3 Apr 2011 19:41:05 -0400	[thread overview]
Message-ID: <257867.782e4d7b.wsc0.mx@tumtum.plumbweb.net> (raw)
In-Reply-To: <86fwpz55nj.fsf@cmarib.ramside>

> One thing that has come to concern me about rc(1) is that read(1) is
> not a "builtin" command.

The general idea here is that forking a new process is not usually
(ever?) the bottleneck, if you have a script that needs to run faster,
there's other overhead to trim first, and if you really need to, you can:
(giving up line at a time response).

ifs=($nl)
lines=`{cat}
for($lines as $line){...}

There isn't any such trick (that I know) for test, but how much is it
slowing you down?

> I'm also a bit stumped by the fact that rc(1) doesn't have anything
> analogous to bash(1)'s string parsing operations: ${foo#bar},
> ${foo##bar}, ${foo%bar}, ${foo%%bar}, or ${foo/bar/baz}.
I could never remember what these did, except the last one.

> Is there any way to extract substrings (or single characters) from a
> string in rc(1) without having to fork a dd, awk, or sed?
Sure, for some things, except it uses cat! Without any forking, I don't
know (see below).

On the other hand, echo -n is a wart. I wonder, does echo '' -n work?
(My plan9 machine is off and far away.)

On a more friendly note. Hi, I think I know you slightly, telephones.

Tristan

-- 
All original matter is hereby placed immediately under the public domain.



  parent reply	other threads:[~2011-04-03 23:41 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-03 22:30 smiley at zenzebra.mv.com
2011-04-03 23:22 ` pmarin
2011-04-03 23:41 ` Tristan Plumb [this message]
2011-04-04  2:02   ` Ethan Grammatikidis
2011-04-04  2:53   ` erik quanstrom
2011-04-04  7:54     ` Tristan Plumb
2011-04-04  9:26     ` roger peppe
2011-04-04 21:35       ` smiley
2011-04-04 21:46         ` Anthony Sorace
2011-04-04 22:03           ` erik quanstrom
2011-04-05  8:57           ` Balwinder S Dheeman
2011-04-04 22:00         ` Oleg Finkelshteyn
2011-04-04 22:33         ` erik quanstrom
2011-04-04 23:01         ` Lyndon Nerenberg
2011-04-05  8:58         ` yy
2011-04-05 19:54           ` Ethan Grammatikidis
2011-04-05 19:56             ` erik quanstrom
2011-04-05 20:54               ` Ethan Grammatikidis
2011-04-05 21:53                 ` andrey mirtchovski
2011-04-06 16:32                   ` Bakul Shah
2011-04-06 16:43                     ` roger peppe
2011-04-06 18:15                       ` erik quanstrom
2011-04-06 18:37                         ` Yaroslav
2011-04-07  8:45                           ` Greg Comeau
2011-04-06 18:18                     ` erik quanstrom
2011-04-07  8:45                     ` Greg Comeau
2011-04-05  9:10         ` roger peppe
2011-04-05 15:47           ` ron minnich
2011-04-05 15:52             ` Jacob Todd
2011-04-05 15:57               ` erik quanstrom
2011-04-05 16:04               ` Rudolf Sykora
2011-04-05 17:17                 ` ron minnich
2011-04-05 17:49             ` smiley
2011-04-05 18:01               ` erik quanstrom
2011-04-05 19:50               ` Yaroslav
2011-04-06 15:27                 ` smiley
2011-04-06 15:32                   ` Jacob Todd
2011-04-07  1:26                     ` [9fans] Busy mouse WAS: " smiley
2011-04-07 11:49                       ` erik quanstrom
2011-04-07 19:59                         ` smiley
2011-04-07 20:19                           ` erik quanstrom
2011-04-09 12:26                             ` smiley
2011-04-09 12:33                               ` erik quanstrom
2011-04-05 16:28         ` [9fans] " dexen deVries
2011-04-05 17:05         ` Bakul Shah
2011-04-03 23:51 ` Lyndon Nerenberg (VE6BBM/VE7TFX)
2011-04-04  3:01 ` erik quanstrom

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=257867.782e4d7b.wsc0.mx@tumtum.plumbweb.net \
    --to=9p-st@imu.li \
    /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).