shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

[Feature Request] Add directives "is_set" and "is_used"

Open Salamandar opened this issue 5 years ago • 0 comments

SC2154 and SC2034 are about unset and unused variables. But when I'm sure a variable is set (in a function with the var name in argument for example), I'd like to tell Shellcheck about it.

I think something like this would be great:

set_variable my_var_name my_var_value
# shellcheck is_set=my_var_name,my_other_var_name

echo "$my_var_name"     # <--- no warning here

same would be for unused variables :

my_new_var="hello world"     # <-- no warning here because of the is_used later

use_variable my_new_var
# shellcheck is_used=my_new_var

Salamandar avatar Jul 22 '20 09:07 Salamandar