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

SC2094, SC2035, SC2034, SC2205, SC2283 ternary arithmetic false positives #2984

Open
4 tasks done
apprehensions opened this issue May 15, 2024 · 0 comments
Open
4 tasks done

Comments

@apprehensions
Copy link

apprehensions commented May 15, 2024

For bugs

  • Rule Id (if any, e.g. SC1000): SC2094, SC2035, SC2034, SC2205, SC2283
  • My shellcheck version (shellcheck --version or "online"): 0.10.0 & online
  • The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
  • I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit

For new checks and feature suggestions

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

#!/bin/sh

foo=1
bar=2

: "$((foo =< bar ? foo : bar))"

Here's what shellcheck currently says:

$ shellcheck myscript
 
foo=1
^-- [SC2034](https://www.shellcheck.net/wiki/SC2034) (warning): foo appears unused. Verify use (or export if used externally).
 
bar=2
^-- [SC2034](https://www.shellcheck.net/wiki/SC2034) (warning): bar appears unused. Verify use (or export if used externally).
 
[Line 6:](javascript:setPosition(6, 4))
: "$((foo =< bar ? foo : bar))"
   ^-- [SC1102](https://www.shellcheck.net/wiki/SC1102) (error): Shells disambiguate $(( differently or not at all. For $(command substitution), add space after $( . For $((arithmetics)), fix parsing errors.
     ^-- [SC2205](https://www.shellcheck.net/wiki/SC2205) (warning): (..) is a subshell. Did you mean [ .. ], a test expression?
          ^-- [SC2283](https://www.shellcheck.net/wiki/SC2283) (error): Remove spaces around = to assign (or use [ ] to compare, or quote '=' if literal).
             ^-- [SC2094](https://www.shellcheck.net/wiki/SC2094) (info): Make sure not to read and write the same file in the same pipeline.
                 ^-- [SC2035](https://www.shellcheck.net/wiki/SC2035) (info): Use ./*glob* or -- *glob* so names with dashes won't become options.
                         ^-- [SC2094](https://www.shellcheck.net/wiki/SC2094) (info): Make sure not to read and write the same file in the same pipeline.

$

Here's what I wanted or expected to see:

$ shellcheck myscript
No issues detected!

$ 
@apprehensions apprehensions changed the title SC2094, SC2035, SC2034, SC2205 ternary arithmetic false positives SC2094, SC2035, SC2034, SC2205, SC2283 ternary arithmetic false positives May 15, 2024
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