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

negation of SC2055, [[ $1 = foo && $1 = bar ]], is not detected #3179

Open
2 of 4 tasks
e-kwsm opened this issue Apr 4, 2025 · 0 comments · May be fixed by #3182
Open
2 of 4 tasks

negation of SC2055, [[ $1 = foo && $1 = bar ]], is not detected #3179

e-kwsm opened this issue Apr 4, 2025 · 0 comments · May be fixed by #3182

Comments

@e-kwsm
Copy link

e-kwsm commented Apr 4, 2025

For bugs

  • Rule Id (if any, e.g. SC1000): SC2055?
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

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

#!/bin/bash
# ! [[ $1 != foo || $1 != bar ]]  # SC2055 is issued
if [[ $1 = foo && $1 = bar ]]
then
  echo "$1 is foo or bar"
fi

Here's what shellcheck currently says:

Nothing.

Here's what I wanted or expected to see:

Line 3:
if [[ $1 = foo && $1 = bar ]]
               ^-- SC2055 (warning): You probably wanted || here, otherwise it's always false.
e-kwsm added a commit to e-kwsm/shellcheck that referenced this issue Apr 4, 2025
- fix koalaman#3179 — negation of SC2055, `[ x = y -a x = z]`
- fix koalaman#3181 — negation of SC2056, `(( x == y && x == z ))`
- fix koalaman#3180 — negation of SC2252, `[ x = y ] && [ x = z ]`
@e-kwsm e-kwsm linked a pull request Apr 4, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant