koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.45k stars 1.78k forks source link

(( arithmetic expressions )) for ksh a Linux flavor #3063

Open LerouxYvon opened 1 month ago

LerouxYvon commented 1 month ago

For bugs

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/bin/ksh
(( X_NB_JOURS = round(X_NB_JOURS) ))

Here's what shellcheck currently says:

Line 2  SC1073: Couldn't parse this ((..)) command. Fix to allow more checks.
Line 2  SC1009: The mentioned syntax error was in this ((..)) command.
Line 2  SC1072:  Fix any mentioned problems and try again.

Here's what I wanted or expected to see:

TODO: Describe expected/desired output Send a warning that the expression is not a "legitimate POXIS Arithmetic expression" or a "Linux flavor". To me, "syntax error " is a very scary error.

Here are all arithmetics functions accepted on Linux KSH93.

abs acos acosh asin asinh atan atan2 atanh cbrt copysign cos cosh erf erfc exp exp2 expm1 fabs fdim finite floor fma fmax fmod hypot ilogb int isinf isnan lgamma log log2 logb nearbyint nextafter nexttoward pow remainder rint round sin sinh sqrt tan tanh tgamma trunc

Check documentation: https://docs.oracle.com/cd/E36784_01/html/E36870/ksh-1.html

Thank you so much for this excellent tool.