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

SC2198 false positive #2923

Open
2 tasks done
maxpagani opened this issue Feb 7, 2024 · 0 comments
Open
2 tasks done

SC2198 false positive #2923

maxpagani opened this issue Feb 7, 2024 · 0 comments

Comments

@maxpagani
Copy link

For bugs

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

#!/usr/bin/env bash
if [ "${@: -1}" == "foo" ]
then
  echo "last arg is 'foo'"
fi

Here's what shellcheck currently says:

Arrays don't work as operands in [ ]. Use a loop (or concatenate with * instead of @).

Here's what I wanted or expected to see:

No error. The expression in the test is not a concatenation, but the extraction of last parameter.

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