-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
For bugs
- Rule Id: SC2155
- My shellcheck version: 0.7.2
- The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2155)
- I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
#!/bin/bash
myfunc() {
local -r x=$(false)
}
Here's what shellcheck currently says:
nothing
Here's what I wanted or expected to see:
I expected the error SC2155: Declare and assign separately to avoid masking return values.
.
This is very subtle mistake to make which can lead to really bad outcomes if you're relying on your script to stop executing on errors. shellcheck is critical to avoid the various pitfalls, and it's too bad that this one is left behind intentionally.
I realize that the doc mentions this case explicitly, but I am perplexed at the justification. I'm sure I'm far from the only person who prefers a little verbosity to incorrect code. Especially since this behavior is untunable and totally silent unless you actually stumble on the issue and notice it.
I understand why some people would prefer a "relaxed/not annoying" version of shellcheck, but it seems to me this ought to be tunable so you are aware of the consequences.