On 4 April 2011 22:35, <smi...@zenzebra.mv.com> wrote: > roger peppe <rogpe...@gmail.com> 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). It outputs a rogue space prior > to the newline. echo, with no arguments, should ouput just a newline.
it works fine, with no rogue spaces. did you try it? > I'm trying to write an Acme client in rc(1). I'd like to avoid spawning > 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. I've managed to peel away the extra layers of code from one 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. The > 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. (There doesn't currently appear to be any such > "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