portability touch-up (and ~15k size-savings)

Rob Landley rob at landley.net
Sun May 28 03:23:09 UTC 2006


On Friday 26 May 2006 7:13 pm, Rich Felker wrote:
> On Fri, May 26, 2006 at 06:46:43PM -0400, Rob Landley wrote:
> > On Thursday 25 May 2006 3:40 pm, Rich Felker wrote:
> > > BTW about getopt_long... it might be worth dropping getopt entirely
> > > and making a lightweight libbb function for handling options (both
> > > short and long).
> >
> > A fresh implementation of bb_getopt_ulflags() that doesn't use getopt at
> > all would be nice.  I'd be especially like it if _this_ one can handle
> > tar xfjCv tarball.tbz dirname . without think that the tarball name I
> > want is "jCv" and that I want to put "tarball.tbz", "dirname", and "." in
> > it...
>
> Umm, I think the 'correct' unix semantics are that jCv is the filename
> in this case, but I'm not sure... Nasty eh? :)

That's not what tar's done for the past decade.  And the "ps ax" stuff also 
uses that strange logic.  Possibly we blame berkeley for this?  Dunno...

> > Of course it depends on whether or not it actually saves size...
>
> As long as it's written efficiently and _all_ references to getopt()
> are removed it should definitely reduce size. With glibc (and uClibc)
> the savings should be fairly significant. Built against my version
> (which doesn't support the argv permutation thing) the savings will
> probably be smaller but still nontrivial.

Never having seen your version, I can't bring myself to care about it.  (And 
yes, my nose has been rubbed in this re: bbsh recently. :)

But there's a lot of stuff that getopt_ulflags should do but doesn't.  The 
biggest offender right now is that it can't automatically fetch a numeric 
argument into an integer.  It should.  Fixing that is a todo item of mine, 
but I've noticed that any time I try to edit vladimir's code it's invariably 
easier to just start over, and I've got too many other todo items right 
now...

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list