Korn shell - evaluating string gives wrong results due to limitations

Anyone ever seen this? Someone mentioned this the other day....

If you do, for instance, in korn shell, echo $(5.2+2.5), it gives the result of 6 regardless.

Can't remember why but it was the limitation of the korn shell.

The command echo $(5.2+2.5) only prints 6 if you have a utiiity named 5.2+2.5 that prints 6. When I run that command on my system, I get the diagnostic:

-ksh: 5.2+2.5: not found

If:

echo $(5.2+2.5)

prints 6 for you, what does the command:

type 5.2+2.5

print?

With a 1993 or later version of the Korn shell, the command echo $((5.2+2.5)) (note the double sets of parentheses) prints 7.7 . With an earlier version of the Korn shell, the results are probably similar to what you get giving that command to bash; a diagnostic something like:

syntax error: invalid arithmetic operator (error token is ".2+2.5")

Not sure of exact command to be honest. Thats the problem.

It was something to do with caused by stack overflow?

"6" as output is dubious:

Legacy ksh (ksh88, integer arithmetics):

$ echo $((5.2+2.5))
7

Current ksh (ksh93, floating point arithmetics):

$ echo $((5.2+2.5))
7.7

You may have been mislead by some of my guesses at what might be going on. The original statement was that the command:

echo $(5.2+2.5)

(note the single set of parentheses) when processed by an unspecified version of the Korn shell produces the output

6

Note that psychocandy has yet to answer the question: What does the command

type 5.2+2.5

produce on a system where echo $(5.2+2.5) prints 6 ?

The chance for a command named "5.2+2.5" to exist on the OP machine is low enough to rule it out thus I assume extra parenthesis were simply missing.

In any case, psychocandy doesn't remember the command typed so my guess is he also fails to remember correctly what was displayed by this command.

This leaves not that much to investigate ...

---------- Post updated at 12:24 ---------- Previous update was at 12:21 ----------

No. Stack overflow is not something to suspect with so little and so low numbers.