Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ksh: Unexpected failure when using functions in arithmetic expressions #2999

Open
4 tasks done
JasonGantner opened this issue Jun 11, 2024 · 0 comments
Open
4 tasks done

Comments

@JasonGantner
Copy link

For bugs

For new checks and feature suggestions

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

#!/bin/ksh
h=22
m=34
INTERVAL=120
  ((count = floor(((23 - h) * 60 + (59 - m)) * (60.0 / INTERVAL))))
echo $count

Here's what shellcheck currently says:

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

Here's what I wanted or expected to see:

No error

ksh supports the following builtin arithmetic functions from the C math library:

abs acos acosh asin asinh atan atan2 atanh cbrt ceil copysign cos cosh erf erfc exp exp10 exp2 expm1 fabs fdim
finite float floor fma fmax fmin fmod fpclass fpclassify hypot ilogb  int  isfinite  isgreater isgreaterequal
isinf isinfinite isless islessequal islessgreater isnan isnormal issubnormal isunordered iszero j0 j1 jn ldexp
lgamma log log10 log1p log2 logb nearbyint nextafter nexttoward pow remainder rint round scalb scalbn  signbit
sin sinh sqrt tan tanh tgamma trunc y0 y1 yn

see man 1 ksh for details or man <(curl -LJ https://github.com/ksh93/ksh/blob/dev/src/cmd/ksh93/sh.1)

On a side note, zsh (which is unsupported, I know) has similar support given the module zsh/mathfunc is loaded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant