[BusyBox] modified libbb/arith.c -- size reduction (30%) and bug fix

Tom Cameron tom at patcameron.ne.mediaone.net
Sun Aug 26 00:48:14 UTC 2001


Aaron,
	I do understand what you mean...and I see where you're going with it. 
I mean, call me the command nazzi (better yet...how bout we skip that),
but I'm looking at it from the stand point, What If(tm) a user has
written a script that has some math stuff in it.  Now lets say said user
botched the parens. (I can't _tell_ you the number of times I've done
this).  Now lets say the math crunching churns out a number...which is
_completely_ wrong...to which this user responds with the standard,
"What the...?".  Now, let's say after hours of debugging, and not
catching the paren. problem, this hypothetical user is standing on the
railing of the nearest bridge, with the local police attempting to coax
him down.  Anyway, you know where I'm going.  I'm just afraid that not
barking at the user may produce some strange effects...ones where parens
should have been, but weren't.  I suppose if we look at it close enough
we could completely discredit my point.

-Tom

P.S. I'm thinking of an example such as ((3+2*3)/(2+1)/2)+1=2.5  Now, if
we leave out a paren., and the arith stuff decides that it belonged in
the wrong place, we may have an arithmatic crisis on our hands (consider
a volume knob for an MP3 player, all controlled by the shell.  The
volume gets too high, boom, the volume gets too low, the listener is
rushing to the doctor's office...concerned about their sudden loss of
hearing.  ;-)

Aaron Lehmann wrote:
> 
> On Sun, Aug 26, 2001 at 01:20:20AM -0400, Tom Cameron wrote:
> > Aaron,
> >       I, for one, do _not_ like the idea of programing around user errors.
> > After working in the computer industry for 12 years, the one thing that
> > I have found is that you should (in a polite way) make people aware of
> > their errors. Even if it makes the final product smaller, I don't like
> > the idea of the shell not telling me that I have made a mistake.
> 
> Erm, I don't think we're talking about quite the same thing. I was
> intending to suggest this modification so users didn't *have* to match
> their parentheses, and the program didn't *have* to check. Forcing the
> user to complete parentheses is like stronly-typing a language: it's a
> double-edged sword. I wasn't thinking of it as excusing errors, but
> rather making the interpreter less strict. Forcing matching parens can
> catch errors, or can be a PITA.
> 
> Of course, this can deviate from the POSIX standard, which I hope to
> avoid. But I don't think that POSIX mandates certain behavior in
> handling uncompliant input. So, while a user should never use the
> extension I'm proposing, it could be convinient because 1) a user
> typing at the shell doesn't have to completely comply with the strict
> POSIX standard for arith, the shell will let them off sometimes  2) it
> is simpler and more understandable for the internal design of the
> arith parser to just let mismatched parens slide. What do you think? I
> understand where you're coming from.





More information about the busybox mailing list