You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Codigo=$?
^-- [SC2320](https://www.shellcheck.net/wiki/SC2320) (warning): This $? refers to echo/printf, not a previous command. Assign to variable to avoid it being overwritten.
Here's what I wanted or expected to see:
An "echo" redirected to a file is a file write operation. It is necessary to obtain the exit code of that operation, because writing to a file will fail due to lack of permissions, and sometimes it is necessary to verify it.
Wiki says:
If you intentionally refer to echo to get the result of a write, you can ignore this message. Alternatively, write it out as in if echo $$ > "$pidfile"; then status=0; else status=1; fi
But, I think that a report should be as clean as possible, and I think it is easy to detect these cases so as not to show warnings.
The text was updated successfully, but these errors were encountered:
Intention is very hard to catch.
I would assume that this is a common error in the wild and that's the reason for having the warning to begin with. And if found it is easy to ignore with a directive as suggested in the wiki.
A patch for making the discovery more robust and to avoid some of these fasle positives is as always welcome.
For bugs
For new checks and feature suggestions
Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
An "echo" redirected to a file is a file write operation. It is necessary to obtain the exit code of that operation, because writing to a file will fail due to lack of permissions, and sometimes it is necessary to verify it.
Wiki says:
But, I think that a report should be as clean as possible, and I think it is easy to detect these cases so as not to show warnings.
The text was updated successfully, but these errors were encountered: