diff --git a/SC2034.md b/SC2034.md index c10662a..60263f2 100644 --- a/SC2034.md +++ b/SC2034.md @@ -35,14 +35,14 @@ It's ShellCheck's intended behavior to emit this warning for any variable that i export "$name"; eval "echo $name" declare -n name; echo "$name" -Tracking indirect references is a common issue for compilers and static analysis tool, and it is known to be unsolvable in the most general case. There are two ways to handle unresolved indirections (which in a realistic program is by far most of them): +This is an intentional design decision and not a bug. If you have variables that will not have direct references, consider using an associative array in bash, or just [[Ignore]] the warning. -* Avoid false positives by disabling all unused variable warnings. -* Keep true positives by allowing some false positives. +Tracking indirect references is a common problem for compilers and static analysis tool, and it is known to be unsolvable in the most general case. There are two ways to handle unresolved indirections (which in a realistic program will essentially be all of them): -ShellCheck intentionally chooses the latter. For consistency and to avoid giving the impression that it should work more generally, it does not attempt to resolve even indirections that seem trivial, like the above. +* Avoid false positives by assuming all variables may potentially be used (disable all unused variable warnings) +* Keep true positives by allowing some false positives (emit unused variable warnings that may be incorrect) -If you have variables that will not have direct references, consider using an associative array in bash, or just [[Ignore]] the warning. You can do this for individual variables, sets of variables, the whole script, or all scripts. +Compilers are forced to do the former, but static analysis tools generally do the latter. This includes `pylint`, `jshint` and `shellcheck` itself. This is a design decision meant to make the tools more helpful at the expense of some noise. For consistency and to avoid giving the impression that it should work more generally, ShellCheck does not attempt to resolve even trivial indirections. #### Intentionally unused variables