From mboxrd@z Thu Jan 1 00:00:00 1970 From: 9p-st@imu.li (Tristan Plumb) Date: Sun, 3 Apr 2011 19:41:05 -0400 Subject: [9fans] Making read(1) an rc(1) builtin? In-Reply-To: <86fwpz55nj.fsf@cmarib.ramside> References: <86fwpz55nj.fsf@cmarib.ramside> Message-ID: <257867.782e4d7b.wsc0.mx@tumtum.plumbweb.net> Topicbox-Message-UUID: c7424edc-ead6-11e9-9d60-3106f5b1d025 > 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.