-
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
[SC2046] false positive from return $([ "$(tput colors)" -ge "8" ])
#3119
Comments
I am not sure that code does what you want it to do but the correct quoting would be the complete subshell (second line in your report). But let's break it down to try to understand what we have. The Starting inside the square brackets we have a subshell excuting
The square bracket comparison will then be passed up a step to the subshell and executed. In most cases I would assume that there are no command 0 nor 1 and thus you'll have "command not found". I think shellcheck does suggest the correct quoting in this case. I am doubting that the code presented is constructed correct. Maybe
|
if [ "$(tput colors)" -ge "8" ]; then
return 0 #standard console
fi
return 1 is a workaround. Too bad that is 4 lines instead of 1 (such as |
Workaround:
reduces those 4 lines to 2. |
For bugs
Here's a snippet or screenshot that shows the problem:
(from SwuduSusuwu/SubStack@5f57561#diff-34e56429da29b8a769483ffcd6eb3c6089937cdc157438b119ae25d2b06750beR59-R69).
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
How to add more quotes, or "Passed".
return $("[ "$(tput colors)" -ge "8" ]")
is a syntax error (outputs[ "256" -ge "8" ]: command not found
), andreturn "$([ "$(tput colors)" -ge "8" ])"
is a syntax error (outputsNo command found
), so do not know how to add more quotes.The text was updated successfully, but these errors were encountered: