shellcheck
shellcheck copied to clipboard
SC2034: Passing by reference is not recognized as usage
For bugs
- Rule Id:
SC2034
- My shellcheck version:
0.7.0
- [X] The rule's wiki page does not already cover this (see https://shellcheck.net/wiki/https://github.com/koalaman/shellcheck/wiki/SC2034)
- [X] I tried on shellcheck.net and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
#!/usr/bin/env bash
process_arr() {
local -n my_arr=$1
my_arr+=('World')
echo "${my_arr[@]}"
}
main() {
local arr=()
arr=('Hello') #SC2034
process_arr arr # pass by reference
}
main
Here's what shellcheck currently says:
Line 11:
arr=('Hello') #SC2034
^-- SC2034: arr appears unused. Verify use (or export if used externally).
Here's what I wanted or expected to see:
Nothing. Passing by reference should be recognized as valid usage.
Issue also exists with shellcheck 0.8.0
+1 for this, very annoying and forces the variable export