Nicolas Williams wrote:
> On Thu, Feb 28, 2008 at 01:35:39AM +0100, Roland Mainz wrote:
> > Nicolas Williams wrote:
> > > On Thu, Feb 28, 2008 at 12:10:30AM +0100, Roland Mainz wrote:
> > > > Nicolas Williams wrote:
> > > > > > > +[[ $# -eq 3 ]] || {
> > > > > >
> > > > > > Ouch... both /usr/bin/ksh and /usr/bin/ksh93 support builtin math
> > > > > > and
> > > > > > comparing strings using the "test" builtin is a bit sub-optimal,
> > > > > > please
> > > > > > use
> > > > >
> > > > > Ouch what? [[ ... ]] uses the built-in test, and surely costs nothing
> > > > > measurable in this case.
> > > >
> > > > Erm... (( )) is a math expression which uses the internal representation
> > >
> > > [long explanation elided]
> > >
> > > I understand, but I this makes not an iota of difference here.
> >
> > Grumpf... think about it this way: in C/C++ you use |int| and not |char
> > *| to compare numbers. My request is to do the same in this case and
> > compare numbers as numbers and not as "strings". Unlike the
> > Thomson/Bourne shells the ksh/ksh93/POSIX shells support numeric
> > datatypes which should be handled via (( )) and not [[ ]] ...
>
> OK, I don't have to
Right... I just wish the arithmetric syntax would always be used when
handling numbers ([1]) since it was the intention of both ksh and POSIX
people to handle numbers this way. In theory you could use [[ ]],
/usr/bin/bc, awk, perl etc. but at least the ksh/POSIX-way is to use the
(( )) syntax.
[1]=Both integer and floating-point to get consistent handling for all
numbers. For integers it may sometimes little more then a different
syntax but then it may help to educate people that there is something
"new" (where "new" means that the (( )) syntax for integers is available
since (AFAIK) ~~1985).
> but I will do this.
Thanks! :-))
> > > Is it a KSH88 built-in? If not, then forget it :)
> >
> > AFAIK it's a ksh88 builtin command (I don't have the matching Solaris
> > sources as "proof" ... but the code for symbols for "true" are near
> > similar symbols for "false" which means they're likely both builtin
> > commands (or somehow else clustered together). For ksh93 the status of
> > builtin commands can be checked (much easier) using the $ builtin #
> > command).
>
> I trussed ksh and sure enough, it's built-in.
Groan... yes... I forgot the simple way to test for this... "truss" ...
;-/
... I need more coffee. MUCH more coffee... ;-(
> So I'll do this too.
Thanks! :-)
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 7950090
(;O/ \/ \O;)