From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <86vcythf8h.fsf@cmarib.ramside> References: <86fwpz55nj.fsf@cmarib.ramside> <257867.782e4d7b.wsc0.mx@tumtum.plumbweb.net> <5ddd9deccbea5e8556dfc0c228b63311@ladd.quanstro.net> <86vcythf8h.fsf@cmarib.ramside> Date: Tue, 5 Apr 2011 10:10:59 +0100 Message-ID: From: roger peppe To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] Making read(1) an rc(1) builtin? Topicbox-Message-UUID: c9c6fe0a-ead6-11e9-9d60-3106f5b1d025 On 4 April 2011 22:35, wrote: > roger peppe writes: > >> when i've needed a "-n safe" version of echo in >> the past, i've used something like this: >> >> fn myecho {echo -n $"* ^ ' >> '} > > That doesn't work right when (~ $#* 0). =C2=A0It outputs a rogue space pr= ior > to the newline. =C2=A0echo, with no arguments, should ouput just a newlin= e. it works fine, with no rogue spaces. did you try it? > I'm trying to write an Acme client in rc(1). =C2=A0I'd like to avoid spaw= ning > a new read(1) process every time I make a keystroke or click the mouse. > Using multi-line reads wouldn't help much, because interactivity needs > to be maintained. > > I'm using rc(1) because the /mnt/acme/%d/events interface is > well-documented (in /sys/doc/acme/acme.ps), but the C code under > /acme/bin/source/ for reading /mnt/acme/%d/events it is definitively > cryptic. =C2=A0I've managed to peel away the extra layers of code from on= e of > the simpler Acme clients, in /acme/bin/source/adict/win.c, and am in the > process of creating a general-purpose Acme event parser in C. =C2=A0The > output of the filter will be in a form easily digestible by scripts, and > would provide a good "skeleton" example of event parsing for other > coders to build upon. =C2=A0(There doesn't currently appear to be any suc= h > "starter code" under /acme/bin/source or /sys/doc.) > > If only Acme put a single extra space immediately prior the first > integer (c0) in it's event messages, this parsing could have been done > almost entirely within rc(1). the usual solution to problems like this is to write a little helper program in C. you might want to look at http://man.cat-v.org/p9p/1/acmeevent