[Toybox] Looking at nl

Rob Landley rob at landley.net
Mon May 27 11:43:03 PDT 2013


On 05/26/2013 12:26:30 AM, idunham at lavabit.com wrote:
> On Sat, May 25, 2013 at 10:08:51PM -0600, Terrel Shumway wrote:
> > On Sat, May 25, 2013 at 5:36 PM,  <idunham at lavabit.com> wrote:
> > > I thought I'd look at what nl takes, since it's not much more than
> > > looping over some lines, incrementing, and formatting the output.
> > > The POSIX reference page is:
> > > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/nl.html
> >
> > An awk wizard could do that in less than a dozen lines. Since awk is
> > already supposed to be in the toybox, why not write nl as a script?
> 
> Awk is on the TODO list for toybox. Big difference there. (ie, unless
> you plan to add awk, that's not a solution in the near future...)
> Not to mention that awk is never really small or fast, and you need a
> pretty full-featured awk version to bootstrap Linux.
> And much as I like it, I'd rather write more C.
> 
> By the way, I already have a skeleton written for nl, along with a  
> plan
> for how to do the rest.
> I have discovered that nl is not quite as trivial to write as it looks
> at first glance, though (you have to consider page, section, line, and
> 11 variables, with a couple subtle points like a 1-char delimiter gets
> ':' appended).

Looking at it, I recall why it's still on the todo list rather than  
done. Still; good starting command nobody else is working on. :)

Would would be really nice is a scripts/test/nl.test (you can use  
head.test as a simple template or cp.test if you need a more elaborate  
example). I try remember to create a test script as I develop a  
command, otherwise I'm running tests of corner cases during development  
that I don't remember to add to the regression testing (to find out  
what breaks on a new release of bionic on 64 bit little endian arm).

Rob
 1369680183.0


More information about the Toybox mailing list