[Toybox] Fwd: [New Toy - patch] add ps & watch

Rob Landley rob at landley.net
Wed Aug 21 00:11:39 PDT 2013


On 08/20/2013 11:15:42 PM, David Seikel wrote:
> On Tue, 20 Aug 2013 15:55:24 -0500 Rob Landley <rob at landley.net>  
> wrote:
> 
> > On 08/20/2013 04:46:20 AM, Ashwini Sharma wrote:
> > > Hi Rob,
> > >
> > >   Attached are the patches for _watch_  and _ps_ command.
> > >
> > > Sent _ps_ again, just in case you lost the last one. This one also
> > > have a
> > > copyright update.
> >
> > I planned to do watch.c after doing less.c because both have the
> > similar "printing a chunk of a larger screen" logic. If your command
> > output produces too many lines, it shouldn't scroll off, but given
> > that it can wrap around to produce more lines, you can't just count
> > lines. For example:
> >
> >    watch 'python -c "print 100*\"abcdefghijklmnopqrstuvwxyz\""'
> >
> > This version just scrolls off. It doesn't capture the output and
> > make an attempt to format it. But toybox needs that logic for less,
> > more, vi, editing command line history...
> 
> I've been thinking about what you said before about my large editor  
> and
> screen handling blob.  I think I have found a way to at least make one
> or two much smaller blobs to help ease it into toybox.  Finding the
> time to get to it is a problem we are all too familiar with.  I'll get
> there, I want to actually use it myself.

I note that busybox gets this wrong (their "watch" shows all output  
each time, scrolling the screen at length for "watch ls -lR /"), so  
it's an easy mistake to make. But I want to be _better_ than busybox.

Also, this is one of them "damn fiddly" bits whith asynchronous ascii  
probing of screen size as part of interactive input, responding to  
dynamic window resizing (keeping in mind that sigwinch won't propogate  
over a serial port), fixing it so the shell notices when it's not  
starting at the left edge (in bash "echo -n walrus" screws up editing  
of the following line; at one point busybox ash got that right because  
I complained), that fun bit about collating escape sequence input while  
also allowing escape by itself to put vi into command mode (I used 1/3  
of a second timeout)...

It's fiddly, but once we've got it right once, the code should apply to  
a lot of situations.

Rob
 1377069099.0


More information about the Toybox mailing list