-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
SC2319 - confused warning message when checking $? inside a function #2571
Comments
I concur that this appears to be a incorrect warning. I received the same warning in a function being called from an exit trap.
running locally with version: 0.9.0 |
Happens here too: #!/bin/bash
if [[ $exit_code -ne 0 ]]; then
:
else
exit_code=$?
fi Line 25:
exit_code=$?
^-- [SC2319](https://www.shellcheck.net/wiki/SC2319) (warning): This $? refers to a condition, not a command. Assign to a variable to avoid it being overwritten. |
@mgsmgit was it fixed? I don't seem to see references from commits to this issue… |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi all!!
Conducted a test on the site https://www.shellcheck.net
I report that this problem is repeated inside a function:
Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Originally posted by @mymegasam in #2544 (comment)
The text was updated successfully, but these errors were encountered: